RCTUtils crash on JSONKit
Hi,guys:
I'm integrating ReactNative to an existing iOS app which has contained POD package JSONKit', '~> 1.4' in it. And it calls RCTUtils crash when RCTBridge init. But if I comment the code below in RCTUtils.m, then my app can runs well.
/* // comment here to bypass JSONKit error
if (JSONKitSelector && [collectionTypes containsObject:[jsonObject classForCoder]]) {
return ((NSString *(*)(id, SEL, int, NSError **))objc_msgSend)(jsonObject, JSONKitSelector, 0, error);
}
*/
- React Native Version: 0.24
- Platform: iOS
- OS: Mac
Here is the crash call stack
#0 0x000000010ba3c762 in jk_encode_add_atom_to_buffer at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2631
#1 0x000000010ba3f88a in jk_encode_add_atom_to_buffer at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2797
#2 0x000000010ba3f88a in jk_encode_add_atom_to_buffer at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2797
#3 0x000000010ba4004d in jk_encode_add_atom_to_buffer at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2827
#4 0x000000010ba3b56b in -[JKSerializer serializeObject:options:encodeOption:error:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2877
#5 0x000000010ba3af8d in +[JKSerializer serializeObject:options:encodeOption:error:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2847
#6 0x000000010ba407c5 in -[NSDictionary(JSONKitSerializing) JSONStringWithOptions:error:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/Pods/JSONKit/JSONKit.m:2997
#7 0x000000010bc6b5ce in _RCTJSONStringifyNoRetry at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTUtils.m:49
#8 0x000000010bc6b343 in RCTJSONStringify at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTUtils.m:77
#9 0x000000010bb739bb in -[RCTBatchedBridge moduleConfig] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBatchedBridge.m:417
#10 0x000000010bb709a6 in __25-[RCTBatchedBridge start]_block_invoke54 at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBatchedBridge.m:134
#11 0x000000011294fe5d in _dispatch_call_block_and_release ()
#12 0x000000011297049b in _dispatch_client_callout ()
#13 0x0000000112953840 in _dispatch_async_redirect_invoke ()
#14 0x000000011297049b in _dispatch_client_callout ()
#15 0x0000000112958bef in _dispatch_root_queue_drain ()
#16 0x00000001129584c5 in _dispatch_worker_thread3 ()
#17 0x0000000112ca868f in _pthread_wqthread ()
#18 0x0000000112ca6365 in start_wqthread ()
Enqueued from com.facebook.react.RCTBridgeQueue (Thread 3)Queue : com.facebook.react.RCTBridgeQueue (serial)
#0 0x000000011295995a in _dispatch_async_f_redirect ()
#1 0x000000010bb706bd in __25-[RCTBatchedBridge start]_block_invoke47 at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBatchedBridge.m:131
#2 0x000000011294fe5d in _dispatch_call_block_and_release ()
#3 0x000000011297049b in _dispatch_client_callout ()
#4 0x0000000112953840 in _dispatch_async_redirect_invoke ()
#5 0x000000011297049b in _dispatch_client_callout ()
#6 0x0000000112958bef in _dispatch_root_queue_drain ()
#7 0x00000001129584c5 in _dispatch_worker_thread3 ()
#8 0x0000000112ca868f in _pthread_wqthread ()
#9 0x0000000112ca6365 in start_wqthread ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0 0x000000011295995a in _dispatch_async_f_redirect ()
#1 0x000000010bb6fe75 in -[RCTBatchedBridge start] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBatchedBridge.m:120
#2 0x000000010bb6fa7d in -[RCTBatchedBridge initWithParentBridge:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBatchedBridge.m:84
#3 0x000000010bb82501 in -[RCTBridge createBatchedBridge] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBridge.m:245
#4 0x000000010bb824a4 in -[RCTBridge setUp] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBridge.m:240
#5 0x000000010bb816e8 in -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/node_modules/react-native/React/Base/RCTBridge.m:136
#6 0x000000010b8954a4 in -[RemixBridgeKeeper initWithBundleURL:launchOptions:moduleProvider:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/remix/sdk/RemixSDKiOS/RemixBridgeKeeper.m:87
#7 0x000000010b8953d4 in -[RemixBridgeKeeper initWithBundleURL:launchOptions:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/remix/sdk/RemixSDKiOS/RemixBridgeKeeper.m:78
#8 0x000000010b8f82d2 in +[RemixBootstrap initBridge:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/RNChunyuClinic/remix/sdk/RemixSDKiOS/RemixBootstrap.m:22
#9 0x000000010b6da480 in -[AppDelegate application:didFinishLaunchingWithOptions:] at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/ChunyuClinic/AppDelegate.m:60
#10 0x000000010f58b1f1 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] ()
#11 0x000000010f58c397 in -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] ()
#12 0x000000010f592cc6 in -[UIApplication _runWithMainScene:transitionContext:completion:] ()
#13 0x000000010f58fe7b in -[UIApplication workspaceDidEndTransaction:] ()
#14 0x0000000113b17754 in -[FBSSerialQueue _performNext] ()
#15 0x0000000113b17ac2 in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#16 0x000000010d732a31 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#17 0x000000010d72895c in __CFRunLoopDoSources0 ()
#18 0x000000010d727e13 in __CFRunLoopRun ()
#19 0x000000010d727828 in CFRunLoopRunSpecific ()
#20 0x000000010f58f7cd in -[UIApplication _run] ()
#21 0x000000010f594610 in UIApplicationMain ()
#22 0x000000010b8cc0a0 in main at /Users/zuozhuo/Workspace/ios/ChunyuClinic3/ChunyuClinic/main.m:18
#23 0x00000001129a492d in start ()
it may be JsonKit's Problem, try to replace the following two code lines in JSONKit.m
line 2603:
void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : *((void **)objectPtr);
=>
void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : object_getClass(objectPtr);
and line 2811
void *keyObjectISA = *((void **)keys[idx]);
=>
void *keyObjectISA = object_getClass(keys[idx]);
reference here: https://github.com/johnezang/JSONKit/issues/176
Well, @fragno thanks for your help.
https://github.com/johnezang/JSONKit/issues/176
@fragno the replacement from *((void **) to object_getClass works after I upgraded RN 0.33 to 0.35
Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.