Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when upgrading from v3.7.0 to v3.8.0 #924

Closed
maciesielka opened this issue Jul 21, 2020 · 0 comments · Fixed by #925
Closed

Crash when upgrading from v3.7.0 to v3.8.0 #924

maciesielka opened this issue Jul 21, 2020 · 0 comments · Fixed by #925

Comments

@maciesielka
Copy link
Contributor

Hey there 👋

I'm experiencing the following crash after upgrading from v3.7.0 to v3.8.0

Invalid number value (NaN) in JSON write

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x18790896c __exceptionPreprocess
1  libobjc.A.dylib                0x187621028 objc_exception_throw
2  Foundation                     0x187d83a18 _writeJSONNumber
3  Foundation                     0x187d84790 ___writeJSONObject_block_invoke
4  Foundation                     0x187d84960 ___writeJSONObject_block_invoke_2
5  CoreFoundation                 0x187958990 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__
6  CoreFoundation                 0x1877da740 -[__NSFrozenDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]
7  Foundation                     0x187d83c80 _writeJSONObject
8  Foundation                     0x187d84790 ___writeJSONObject_block_invoke
9  Foundation                     0x187d84960 ___writeJSONObject_block_invoke_2
10 CoreFoundation                 0x187958990 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__
11 CoreFoundation                 0x1877da740 -[__NSFrozenDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]
12 Foundation                     0x187d83c80 _writeJSONObject
13 Foundation                     0x187d84ab0 ___writeJSONArray_block_invoke
14 CoreFoundation                 0x1878da66c __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
15 CoreFoundation                 0x1877d8d60 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:]
16 Foundation                     0x187d8414c _writeJSONArray
17 Foundation                     0x187c2c764 -[_NSJSONWriter dataWithRootObject:options:error:]
18 Foundation                     0x187c2c3fc +[NSJSONSerialization dataWithJSONObject:options:error:]
19 Analytics                      0x10126f90c -[SEGFileStorage dataFromJSON:] + 190 (SEGFileStorage.m:190)
20 Analytics                      0x10126f84c -[SEGFileStorage setJSON:forKey:] + 179 (SEGFileStorage.m:179)
21 Analytics                      0x10126f3a4 -[SEGFileStorage setArray:forKey:] + 107 (SEGFileStorage.m:107)
22 Analytics                      0x10127a0bc -[SEGSegmentIntegration persistQueue] + 655 (SEGSegmentIntegration.m:655)
23 Analytics                      0x101279d44 __34-[SEGSegmentIntegration sendData:]_block_invoke_2 + 590 (SEGSegmentIntegration.m:590)

While TimeInterval.nan is a valid value used in NSPropertyListSerialization, it throws an exception when used in NSJSONSerialization which went unhandled in #854.

New events that attempt to include this value are disregarded gracefully by the try/catch found below, but this doesn't protect against already persisted plists that may fail conversion to JSON and cause crashes on flushing.

- (void)queuePayload:(NSDictionary *)payload
{
@try {
// Trim the queue to maxQueueSize - 1 before we add a new element.
trimQueue(self.queue, self.analytics.configuration.maxQueueSize - 1);
[self.queue addObject:payload];
[self persistQueue];
[self flushQueueByLength];
}
@catch (NSException *exception) {
SEGLog(@"%@ Error writing payload: %@", self, exception);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant