SIGSEGV crash with ART library on Android
This issue is somewhat intermittent, but I have managed to create a minimal example that will crash with some regularity. When the ART library is used to render a component it seems it will cause a crash on Android after it has rendered several times. This issue happens looks to have started with React Native 0.21 and only happens on Android.
Unfortunately the crash happens deep in libc and tracing the cause of the issue has been difficult. The code below reproduces the issue on Android. It will sometimes crash quite quickly (within seconds) and sometimes takes a bit longer (tens of seconds) with an error in the log like:
A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9fa40028 in tid 4388 (mqt_js)
import React, { Text, View } from 'react-native';
const { Surface, Group, Shape } = React.ART;
const Smiley = React.createClass({
render() {
return (
<Surface width={32} height={32}>
<Group scaleX={1} scaleY={1} rotation={this.props.rotation} originX={16} originY={16} opacity={this.props.opacity}>
<Group>
<Shape fill="#222" d="M16 .004 c-8.837 0 -16 7.164 -16 16 0 8.837 7.163 16 16 16 s16 -7.163 16 -16 c0 -8.836 -7.163 -16 -16 -16 z m0 29 c-7.16 0 -12.985 -5.832 -12.985 -13 s5.825 -13 12.985 -13 c7.16 0 12.985 5.832 12.985 13 s-5.825 13 -12.985 13 z"/>
<Shape fill="#222" d="M7.932 12.77 A2.513 2.5 0 1 0 12.958 12.77 A2.513 2.5 0 1 0 7.932 12.77 z"/>
<Shape fill="#222" d="M18.872 12.77 A2.513 2.5 0 1 0 23.898000000000003 12.77 A2.513 2.5 0 1 0 18.872 12.77 z"/>
<Shape fill="#222" d="M24.054 18.39 a1.006 1.006 0 0 0 -.85 .01 c-.005 .004 -.01 .003 -.015 .006 l-.98 .506 c-.62 .278 -1.4 .664 -2.43 .992 -1.04 .328 -2.53 .503 -4.09 .575 -1.56 -.08 -3.05 -.25 -4.09 -.58 -1.04 -.33 -1.82 -.72 -2.43 -.99 l-.97 -.51 -.02 -.01 a1 1 0 0 0 -.85 -.01 .992 .992 0 0 0 -.5 1.32 c1.59 3.502 4.93 5.79 8.58 5.946 .05 .01 .5 .01 .552 0 3.65 -.16 6.99 -2.444 8.582 -5.946 a1 1 0 0 0 -.503 -1.322 z"/>
</Group>
</Group>
</Surface>
);
},
});
class CrashTestDummy extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0,
};
}
componentDidMount() {
setInterval(() => { this.state && this.setState({count: this.state.count + 1}) }, 20);
}
render() {
return (
<View style={{flex: 1, justifyContent: "center", alignItems: "center"}}>
<Text>
Count: {this.state.count}
</Text>
<Smiley/>
</View>
);
}
}
React.AppRegistry.registerComponent('CrashTestDummy', () => CrashTestDummy);
I've noticed that when I use a more complex component that contains more ART elements, it crashes more quickly, suggesting a memory issue.
I'm having this issue too. I started using react-native-art-svg to implement a radial progress/timer bar around a button; now after an inconsistent amount of time of that bar ticking away my app crashes on Android.
Here's the console output for when my app crashes:
04-08 11:28:54.660 202-202/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-08 11:28:54.660 202-202/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0.1/MMB29V/2554798:user/release-keys'
04-08 11:28:54.660 202-202/? A/DEBUG: Revision: '0'
04-08 11:28:54.660 202-202/? A/DEBUG: ABI: 'arm'
04-08 11:28:54.661 202-202/? A/DEBUG: pid: 23720, tid: 23758, name: mqt_js >>> com.redwerks.mindmonkey <<<
04-08 11:28:54.661 202-202/? A/DEBUG: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x971a0084
04-08 11:28:54.708 202-202/? A/DEBUG: r0 9c6369d0 r1 0000001a r2 0000001c r3 fffffffe
04-08 11:28:54.708 202-202/? A/DEBUG: r4 9719ffa0 r5 af00a9e0 r6 9719ffa4 r7 9f3fe498
04-08 11:28:54.708 202-202/? A/DEBUG: r8 00000003 r9 fffffffb sl 9f0b2834 fp 9f4040a4
04-08 11:28:54.708 202-202/? A/DEBUG: ip 00000020 sp 9f3fe3d0 lr aef39907 pc 9ed0bb06 cpsr 80010030
04-08 11:28:54.709 202-202/? A/DEBUG: #00 pc 00006b06 <unknown>
04-08 11:28:54.710 202-202/? A/DEBUG: #01 pc 000fe903 /data/app/com.redwerks.mindmonkey-1/lib/arm/libjsc.so
04-08 11:28:54.710 202-202/? A/DEBUG: #02 pc fffffff9 <unknown>
04-08 11:28:55.554 202-202/? E/DEBUG: AM write failed: Broken pipe
04-08 11:28:55.557 781-797/? I/BootReceiver: Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
04-08 11:28:55.566 781-24304/? W/ActivityManager: Force finishing activity com.redwerks.mindmonkey/.MainActivity
04-08 11:28:55.605 781-1031/? I/WindowState: WIN DEATH: Window{97beca7 u0 com.redwerks.mindmonkey/com.redwerks.mindmonkey.MainActivity}
04-08 11:28:55.606 781-1345/? D/GraphicsStats: Buffer count: 8
04-08 11:28:55.633 216-216/? I/Zygote: Process 23720 exited due to signal (11)
04-08 11:28:55.654 781-791/? I/ActivityManager: Process com.redwerks.mindmonkey (pid 23720) has died
04-08 11:28:55.674 781-8966/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-08 11:28:56.185 781-799/? W/WindowAnimator: Failed to dispatch window animation state change.
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:123)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
I've just confirmed that this issue still exists in v0.23.1
I am seeing a similar error message as well on Android: I am getting this: A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x4604b088 in tid 3316 (mqt_js) I am trying the same application on 2 different android versions:
- On Samsung S6 with Android version 5.1.1, it crashes all the time at boot
- On Nexus 5 with Android version 6.0, I could not see this issue.
The log output in the failing case:
This issue still exists in v0.24.1
+1
I noticed if you turn off debug mode it doesn't crash.
As far as I recall, it does crash when debug mode is turned off - it just takes longer for the crash to happen.
+1
+1
Anyone have an idea for a workaround? Since there seems to be some kind of memory leak, is there a way we can manually call some kind of garbage collection? I need my app to be able to run all day, while it always crashes at best about every ~12 hours.
+1
+1
We see this too. A lot in debug mode. From the dumps, it looks like a crash on the JSC (JavaScriptCore) execution thread.
I started thinking in terms of building a debug version of JSC to see if we could get more information. What I found wasn't entirely encouraging. The JSC build used in React Native seems to come from here:
https://github.com/facebook/android-jsc
and is only buildable with Buck out of the box. I also looked to see which version of JSC it was based on. In fetch_sources.sh it grabs:
http://builds.nightly.webkit.org/files/trunk/src/WebKit-r174650.tar.bz2
I searched for that version here:
https://webkit.org/nightly/archives/
and the timestamp on it is: October 14, 2014 1:09 PM GMT.
I would suggest that the dependence of React Native for Android on an 18 month old (and counting) snapshot of JSC should be of some concern to us all.
I'm continuing to experiment with this off to the side. I find that if I rebuild android-jsc with JIT compilation fully disabled and relink our app with it, it no longer crashes in debug mode on Android.
This doesn't necessarily mean that JIT compilation is buggy I guess; it could just be that memory pressure is reduced slightly and/or it perturbs the timing of something enough to hide the problem.
FWIW, the published android-jsc seems to use this compile time configuration of JavaScriptCore:
preprocessor_flags = [
'-DWTF_USE_EXPORT_MACROS=1',
'-DBUILDING_JavaScriptCore=1',
'-DENABLE_JIT=1',
'-DENABLE_DFG_JIT=0',
'-DENABLE_LLINT=1',
'-DINTPTR_MAX=LONG_MAX',
'-DLOG_TAG="JavaScriptCore"',
],
which I think gives us the Baseline JIT only. JSC has layered JIT solutions - see these:
https://webkit.org/blog/3362/introducing-the-webkit-ftl-jit/ https://trac.webkit.org/wiki/JavaScriptCore
for example.
Anyway, flipping to ENABLE_JIT=0 (in a couple of places in the BUCK file) changes the behaviour of things enough to stop the crashing so far. But trials continue.
I was able to reproduce it consistently in our project. I get the same crash every time I'm making a call to a server and the response is NOT a 2xx response. It crashes for 4xx, 5xx and so on.
However, when I tried to reproduce it in isolation, by creating a new project, the crash would not depend on the server's response. It would solely depend on how many components are being loaded.
Also, FWIW, for me, the crash does not happen when I'm connected to the Chrome Debugger. Only happens if I'm not connected, which is bad because it happens in production.
See my comment here: https://github.com/magicismight/react-native-svg/issues/38#issuecomment-228360483
For me this is still crashing in 0.28. Anyone else has this problem?
+1
Yeah, not sure if this is related to ART for me anymore, but I do have 2 views overlaying one another when this happens, both containing ART code.
Did anyone find any workaround or solution to this? I am facing the same issue.