react-native: 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.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 29
- Comments: 49 (16 by maintainers)
Did anyone find any workaround or solution to this? I am facing the same issue.
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.
still get this issue, I have try 3 diff android emulator, on
Nexus 4 API 22
, it is just work fine, onNexus 5X API 23
, it crash!!! onNexus 6 API P
, it is work fine too.RN Version:
0.55.2
crash logs:
The issue still persists! Any help would be appreciated.
I am still meeting with this problem on 0.44.2.
Today I upgrade the version of react-native from 0.41.2 to 0.44.2, along with the react module version to 16.0.0-alpha.6. The app runs well at first, but it suddenly starts crashing and can never get started.
I have tried set
android:largeHeap="true"
, but it does not help. I am testing my app on emulator, I don’t know whether platform is related or not. Here is my log:However, the release app runs well. 😦
Still getting crashes in the test repo above with RN 0.37
I put together a repo that reproduces the crash, just clone and
npm install
https://github.com/happypancake/animatedcrashWhen we run it with JS Dev Mode turned on in an Android emulator, or an older device (Galaxy Nexus) it crashes reliably after 3-20 clicks on the heart. With JS Dev Mode off, my fingers got tired before any crashes. Same on a modern flagship phone with JS Dev Mode on, seemingly no crashes.
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:
The log output in the failing case:
logfailure.txt
Having the same problem when i render a big amount of svg’s.
React-Native v0.31 Samsung S5 mini, Android v5.1.1
For me adding: android:largeHeap=“true” in the application in the AndroidManifest resolve the issue.
We might have found the cause for this crash, see PR #11804. Can you check whether the proposed fix solves this crash?
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.
This issue still exists in v0.24.1
I’ve just confirmed that this issue still exists in v0.23.1
Why is this closed while still happening? I’m on 0.47.2. None of proposed fixes works.
Same problem here with RN 0.38.0 on Android 5.
A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xcbd400a4 in tid 15158 (mqt_js)
I can reproduce it with animatedcrash app made by @iggyfisk (thanks!) when JS Dev Mode is on. I can not reproduce it on my app andanimatedcrash
app when JS Dev Mode is off. I don’t use ART directly in my app. (Not sure the libraries use it.) Probably, it’sAnimated
’s problem.