inaka/EventSource

NSRangeException

PashaKharambura opened this issue · 4 comments

Sometimes, my app crashes and give me smth like this:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteMutableData rangeOfData:options:range:]: range {588, 18446744073709551038} causes integer overflow'
*** First throw call stack:
(0x18240b164 0x181654528 0x18240b0ac 0x182d98a54 0x10131ffcc 0x10131f9d8 0x10131e9fc 0x10131eaec 0x182b47970 0x182de1ba0 0x182d21894 0x182d114c4 0x10401d28c 0x1040299e4 0x10401d28c 0x1040299e4 0x1040298a4 0x182de3878 0x10401d28c 0x10402a678 0x104028f08 0x10402e9d0 0x10402e6f4 0x18203306c 0x182032b6c)
libc++abi.dylib: terminating with uncaught exception of type NSException

What you can tell me about this?

can you provide the event that is causing that? @PashaKharambura

Hello! I have the same issue. It occurs rarely, so I have report only from Crashlytics.

Fatal Exception: NSRangeException
0 CoreFoundation 0x1829e4ec4 __exceptionPreprocess
1 libobjc.A.dylib 0x181bb5a40 objc_exception_throw
2 CoreFoundation 0x1828eb594 -[NSCache init]
3 Foundation 0x1833da244 -[NSData(NSData) rangeOfData:options:range:]
4 S1lk 0x102e56bf8 $S4S1lk11EventSourceC09searchForB7InRange33_33D14C5C3D5305202A11BAE60E319258LLySo8_NSRangeVSgAGF (EventSource.swift:248)
5 S1lk 0x102e56654 $S4S1lk11EventSourceC23extractEventsFromBuffer33_33D14C5C3D5305202A11BAE60E319258LLSaySSGyF (EventSource.swift:222)
6 S1lk 0x102e552e8 $S4S1lk11EventSourceC10urlSession_8dataTask10didReceiveySo12NSURLSessionC_So0j4DataG0C10Foundation0K0VtF (EventSource.swift:159)
7 S1lk 0x102e553b4 $S4S1lk11EventSourceC10urlSession_8dataTask10didReceiveySo12NSURLSessionC_So0j4DataG0C10Foundation0K0VtFTo ()
8 CFNetwork 0x183180b94 __67-[NSURLSession delegate_dataTask:didReceiveData:completionHandler:]_block_invoke.303
9 Foundation 0x1834748bc NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK
10 Foundation 0x18337cab8 -[NSBlockOperation main]
11 Foundation 0x18337bf8c -[__NSOperationInternal _start:]
12 Foundation 0x183476790 __NSOQSchedule_f
13 libdispatch.dylib 0x18241d6c8 _dispatch_call_block_and_release
14 libdispatch.dylib 0x18241e484 _dispatch_client_callout
15 libdispatch.dylib 0x1823c182c _dispatch_continuation_pop$VARIANT$mp
16 libdispatch.dylib 0x1823c0ef4 _dispatch_async_redirect_invoke
17 libdispatch.dylib 0x1823cda18 _dispatch_root_queue_drain
18 libdispatch.dylib 0x1823ce2c0 _dispatch_worker_thread2
19 libsystem_pthread.dylib 0x18260117c _pthread_wqthread
20 libsystem_pthread.dylib 0x182603cec start_wqthread

Oddly enough - we've just encountered the same issue:

Fatal Exception: NSRangeException*** -[NSConcreteMutableData rangeOfData:options:range:]: range {3613, 18446744073709548003} causes integer overflow Raw Text
--
 Fatal Exception: NSRangeException
0  CoreFoundation                 0x228388ec4 __exceptionPreprocess
1  libobjc.A.dylib                0x227559a40 objc_exception_throw
2  CoreFoundation                 0x22828f594 -[NSCache init]
3  Foundation                     0x228d7e1b8 -[NSData(NSData) rangeOfData:options:range:]
4  IKEventSource                  0x105be4254 $S13IKEventSource05EventB0C09searchForC7InRange33_373396BB469D4E35C04EEBDAA9A3D90FLLySo8_NSRangeVSgAGF (EventSource.swift:248)
5  IKEventSource                  0x105be3e24 EventSource.extractEventsFromBuffer() (EventSource.swift:222)
6  IKEventSource                  0x105bec120 specialized EventSourceurlSession first-element-marker didReceive(_:_:_:) (EventSource.swift:159)
7  IKEventSource                  0x105be37bc @objc EventSourceurlSession first-element-marker didReceive(_:_:_:) (<compiler-generated>)
8  CFNetwork                      0x228b24b94 __67-[NSURLSession delegate_dataTask:didReceiveData:completionHandler:]_block_invoke.303
9  Foundation                     0x228e188bc __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
10 Foundation                     0x228d20ab8 -[NSBlockOperation main]
11 Foundation                     0x228d1ff8c -[__NSOperationInternal _start:]
12 Foundation                     0x228e1a790 __NSOQSchedule_f
13 libdispatch.dylib              0x227dc16c8 _dispatch_call_block_and_release
14 libdispatch.dylib              0x227dc2484 _dispatch_client_callout
15 libdispatch.dylib              0x227d98e04 _dispatch_continuation_pop$VARIANT$armv81
16 libdispatch.dylib              0x227d984e8 _dispatch_async_redirect_invoke
17 libdispatch.dylib              0x227da4aec _dispatch_root_queue_drain
18 libdispatch.dylib              0x227da534c _dispatch_worker_thread2
19 libsystem_pthread.dylib        0x227fa517c _pthread_wqthread
20 libsystem_pthread.dylib        0x227fa7cec start_wqthread

We haven't successfully reproduced it yet though.

I pushed a big update. It's a breaking update, the API is not the same as previous version but it's easier to track problems and gives more "power" to the user.

I payed special attention to try to reproduce this but I couldn't. If you wanna give a try to the new version and let me know how it goes it would be great!