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

[iOS] crash in facebook::react::Value::toJSONString #22682

Closed
noahtallen opened this issue Dec 17, 2018 · 12 comments
Closed

[iOS] crash in facebook::react::Value::toJSONString #22682

noahtallen opened this issue Dec 17, 2018 · 12 comments
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@noahtallen
Copy link

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
      Memory: 30.55 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.11.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        Build Tools: 27.0.3, 28.0.3
        API Levels: 23, 25, 26, 27
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5014246
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3 
      react-native: 0.57.8 => 0.57.8 

Description

In production, our app is getting a crash. (I believe react-native version for the published version which got the crash is 0.57.5).

Device information:
iPhone 6 on iOS 11.0.3
Available Storage: 21.26 GB
Available RAM: 123.89 MB

Here is the overview from Crashlytics:
screen shot 2018-12-17 at 11 13 34 am

Here's the entire log
Crashed: com.facebook.react.JavaScript
0  JavaScriptCore                 0x18e0a4630 bmalloc::Heap::allocateLarge(std::__1::lock_guard<bmalloc::StaticMutex>&, unsigned long, unsigned long) + 24
1  JavaScriptCore                 0x18e0a4624 bmalloc::Heap::allocateLarge(std::__1::lock_guard<bmalloc::StaticMutex>&, unsigned long, unsigned long) + 12
2  JavaScriptCore                 0x18e0a1ea4 bmalloc::Allocator::allocateLarge(unsigned long) + 92
3  JavaScriptCore                 0x18d760a04 WTF::fastMalloc(unsigned long) + 112
4  JavaScriptCore                 0x18d771d50 WTF::StringImpl::createUninitialized(unsigned int, unsigned short*&) + 64
5  JavaScriptCore                 0x18d771bf8 WTF::StringBuilder::allocateBufferUpConvert(unsigned char const*, unsigned int) + 48
6  JavaScriptCore                 0x18e08f6f0 WTF::StringBuilder::appendQuotedJSONString(WTF::String const&) + 164
7  JavaScriptCore                 0x18de022cc JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&, JSC::JSValue, JSC::Stringifier::Holder const&, JSC::PropertyNameForFunctionCall const&) + 3084
8  JavaScriptCore                 0x18de034b8 JSC::Stringifier::Holder::appendNextProperty(JSC::Stringifier&, WTF::StringBuilder&) + 3016
9  JavaScriptCore                 0x18de025d4 JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&, JSC::JSValue, JSC::Stringifier::Holder const&, JSC::PropertyNameForFunctionCall const&) + 3860
10 JavaScriptCore                 0x18de014e0 JSC::Stringifier::stringify(JSC::Handle<JSC::Unknown>) + 272
11 JavaScriptCore                 0x18de05bc4 JSC::JSONStringify(JSC::ExecState*, JSC::JSValue, unsigned int) + 280
12 JavaScriptCore                 0x18de492b0 JSValueCreateJSONString + 80
13 zonder                         0x10038be5c facebook::react::Value::toJSONString(unsigned int) const + 219236
14 zonder                         0x1003ad76c facebook::react::JSCExecutor::flushQueueImmediate(facebook::react::Value&&) + 124924
15 zonder                         0x1003add18 facebook::react::JSCExecutor::nativeFlushQueueImmediate(unsigned long, OpaqueJSValue const* const*) + 126376
16 zonder                         0x1003ae720 OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::nativeFlushQueueImmediate(unsigned long, OpaqueJSValue const* const*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**)::funcWrapper::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 128944
17 JavaScriptCore                 0x18ddafd90 long long JSC::APICallbackFunction::call<JSC::JSCallbackFunction>(JSC::ExecState*) + 348
18 JavaScriptCore                 0x18d79b28c JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 440
19 JavaScriptCore                 0x18de9aa84 llint_entry + 26980
20 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
21 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
22 JavaScriptCore                 0x18de9aa94 llint_entry + 26996
23 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
24 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
25 JavaScriptCore                 0x18de9add0 llint_entry + 27824
26 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
27 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
28 JavaScriptCore                 0x18de9aa94 llint_entry + 26996
29 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
30 JavaScriptCore                 0x18de9aee0 llint_entry + 28096
31 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
32 JavaScriptCore                 0x18de9aa94 llint_entry + 26996
33 JavaScriptCore                 0x18de9aa30 llint_entry + 26896
34 JavaScriptCore                 0x18de93f50 vmEntryToJavaScript + 272
35 JavaScriptCore                 0x18dd79b94 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 136
36 JavaScriptCore                 0x18d79f1b8 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 400
37 JavaScriptCore                 0x18ddaec3c JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 452
38 JavaScriptCore                 0x18de94098 vmEntryToNative + 280
39 JavaScriptCore                 0x18d79f200 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 472
40 JavaScriptCore                 0x18d9f21fc JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 168
41 JavaScriptCore                 0x18d79ef68 JSObjectCallAsFunction + 368
42 zonder                         0x10038ca54 facebook::react::Object::callAsFunction(OpaqueJSValue*, int, OpaqueJSValue const* const*) const + 222300
43 zonder                         0x1003ad234 facebook::react::JSCExecutor::callFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, folly::dynamic const&) + 123588
44 zonder                         0x1003b3810 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const + 149664
45 zonder                         0x1003279d4 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 1072792
46 zonder                         0x10031d618 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) + 1030876
47 CoreFoundation                 0x186e0816c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
48 CoreFoundation                 0x186e07a3c __CFRunLoopDoBlocks + 288
49 CoreFoundation                 0x186e05ca4 __CFRunLoopRun + 2436
50 CoreFoundation                 0x186d262d8 CFRunLoopRunSpecific + 436
51 zonder                         0x1002fe908 +[RCTCxxBridge runRunLoop] + 904652
52 Foundation                     0x18784f860 __NSThread__start__ + 996
53 libsystem_pthread.dylib        0x186a8c32c _pthread_body + 308
54 libsystem_pthread.dylib        0x186a8c1f8 _pthread_body + 310
55 libsystem_pthread.dylib        0x186a8ac38 thread_start + 4

My guess is that our redux state is large enough that there was not enough available RAM to persist it over the bridge via redux-persist. But I'm not 100% on that. It seems really likely, though, considering all the information on the issue I have linked below:

I'm not sure what the solution should be for this issue. I think there should be some sort of feedback when this sort of situation arises, at least. Some mentioned that it is possible to chunk large strings up into smaller values to conserve RAM, though if that is necessary it should probably happen in react-native itself. If anyone could point me to the source code where this would be an issue, I would be willing to investigate further and potentially submit a PR.

Reproducible Demo

I have been unable to reproduce this issue in development mode. However, there is a lot of context about it in this identical issue which was closed a while ago due to it being an old version of react native.

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Dec 17, 2018
@sryze
Copy link
Contributor

sryze commented Dec 18, 2018

I think this has been fixed in 0.57.6 (#22412), see the comments in #22116 (or maybe it's a different bug?)

@noahtallen
Copy link
Author

Possibly! I believe the published version is on 0.57.5. everyone will get 0.57.8 in our next release though. I'm inclined to believe it's a different bug because #16099 is the exact same issue as mine but opened a year ago, whereas the ones you pointed to were recently introduced changes. (The bot told us to open a new issue if it was still happening).

@el-lsan
Copy link

el-lsan commented Jan 8, 2019

I'm facing the same issue on release version of my app and can't reproduce it on debug mode 🤦‍♂️

@el-lsan
Copy link

el-lsan commented Jan 15, 2019

Any workaround ?

@noahtallen
Copy link
Author

I'm only getting it for a couple users in prod, so I haven't been able to figure it out

@Xyzor
Copy link

Xyzor commented Feb 7, 2019

I'm getting a really similar crash report, also only on production, but on android devices.
I think the two are related.

UPDATE: I created a stackoverflow post with more details.

Log
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #00 pc 003b3ac0  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #01 pc 003b1601  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #02 pc 00364861  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #03 pc 0037134d  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #04 pc 003706c1  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #05 pc 00370e55  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #06 pc 00290f71  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #07 pc 00291fbd  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #08 pc 002913ab  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #09 pc 002908d9  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #10 pc 0029402f  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #11 pc 0005e669  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so (JSValueCreateJSONString+72)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #12 pc 0003b3b9  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZNK8facebook5react5Value12toJSONStringEj+20)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #13 pc 00033c3b  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor19flushQueueImmediateEONS0_5ValueE+26)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #14 pc 00033d6f  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor25nativeFlushQueueImmediateEjPKPK13OpaqueJSValue+86)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #15 pc 00034ab1  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #16 pc 0004eda9  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #17 pc 0012fa9b  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #18 pc 0012f60d  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:52.073 1257-10138/? W/ActivityManager:   Force finishing activity com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity
2019-02-07 14:22:52.140 1257-1272/? D/ViewRootImpl@2042207[timer]: ThreadedRenderer.create() translucent=true
2019-02-07 14:22:52.142 1257-1272/? D/WindowManager: openInputChannel mInputChannel: a585ad2 Application Error: com.xyzor.timer (server)
2019-02-07 14:22:52.144 1257-1272/? D/ViewRootImpl@2042207[timer]: setView = DecorView@83d521e[timer] touchMode=true
2019-02-07 14:22:52.162 7102-10144/? W/PkgUtils: p: com.xyzor.timer, u:0
2019-02-07 14:22:52.167 1257-1272/? D/ViewRootImpl@2042207[timer]: dispatchAttachedToWindow
2019-02-07 14:22:52.194 1257-1272/? D/ViewRootImpl@2042207[timer]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[256,816][1280,1279] result=0x27 surface={isValid=true 547307523072} surfaceGenerationChanged=true
2019-02-07 14:22:52.194 1257-1272/? D/ViewRootImpl@2042207[timer]: mHardwareRenderer.initialize() mSurface={isValid=true 547307523072} hwInitialized=true
2019-02-07 14:22:52.197 1257-1272/? D/ViewRootImpl@2042207[timer]: MSG_WINDOW_FOCUS_CHANGED 1
2019-02-07 14:22:52.197 1257-1272/? D/ViewRootImpl@2042207[timer]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 547307523072}
2019-02-07 14:22:52.209 7187-7204/? W/PkgUtils: p: com.xyzor.timer, u:0
2019-02-07 14:22:52.230 1257-1272/? D/WindowManager: finishDrawingWindow: Window{a585ad2d0 u0 Application Error: com.xyzor.timer} mDrawState=DRAW_PENDING
2019-02-07 14:22:52.231 1257-1272/? D/ViewRootImpl@2042207[timer]: MSG_RESIZED_REPORT: frame=Rect(256, 816 - 1280, 1279) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
2019-02-07 14:22:52.236 1257-1272/? D/WindowManager: finishDrawingWindow: Window{a585ad2d0 u0 Application Error: com.xyzor.timer} mDrawState=HAS_DRAWN
2019-02-07 14:22:52.448 1257-1385/? I/WindowManager: WIN DEATH: Window{2a8ca6fd0 u0 com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity}
2019-02-07 14:22:52.449 1257-1385/? D/WindowManager: disposeInputChannel mInputChannel: 2a8ca6f com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity (server)
2019-02-07 14:22:52.449 1257-2210/? I/ActivityManager: Process com.xyzor.timer (pid 9982) has died(864,760)

@karimbutt
Copy link

@noahtallen did the update to 0.57.8 resolve the issue for you?

@noahtallen
Copy link
Author

hmm.. We're on 0.59.8 now. Looking through our crash reports, I don't see any recent reports of this issue. Perhaps it's fixed! I was never able to reproduce it, so I can't say for sure. I think I'll close this issue then? Let me know if I should reopen it.

@karimbutt
Copy link

Thanks @noahtallen - that gives me hope :)

@lucaspiressimao
Copy link

I'm facing the same problem, any workarounds?

@noahtallen
Copy link
Author

RIP. I never figured it out. I'm assuming you're on the latest version? If so, I'll reopen

@lucaspiressimao
Copy link

RIP. I never figured it out. I'm assuming you're on the latest version? If so, I'll reopen

Im trying to replicate in 0.60.4. Any updates Ill post here

@facebook facebook locked as resolved and limited conversation to collaborators May 15, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants