fix: fix crash due data race on globalMarkdownWorkletRuntime#752
fix: fix crash due data race on globalMarkdownWorkletRuntime#752linhvovan29546 wants to merge 3 commits intoExpensify:mainfrom
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Hi! Thank you for your contribution! Do we have some E/App PR to test the change in app? Let's make sure it doesn't break anything there |
No, I only applied a manual patch to E/App to test it locally. |
|
@linhvovan29546 so how about preparing an E/App PR with "@expensify/react-native-live-markdown": "git+https://github.com/Expensify/react-native-live-markdown.git#19ad58c01e0e22b36c4d889a44a47fc4431303c8",in package.json, and generating adhoc builds to make sure we don't break anything? |
|
I can still reproduce this on the adhoc build. See the Sentry log: Sentry issue. So this PR does not resolve the problem. |
|
Hi @war-in @tomekzaw The crash is a SIGSEGV (signal 11, SEGV_ACCERR) deep in the Hermes GC: RCA: When the Solution: In react-native-worklets/Common/cpp/worklets/SharedItems/Serializable.h, |
|
I'm not very familiar with worklets. The RCA and proposed solution were provided by |
|
Hey, Worklets maintainer here, do you have a good reproducer for that? I think the solution Claude proposed could result in massive memory leaks. Also It could be that the runtime died just after it was checked that it's alive but before the destructor was called. I'll try to make a patch for it so we could verify that. |
|
@tjzel Thanks, I don’t have a reliable reproducer. I reproduced it in the |
|
Please let me know if I can help, as I’m able to reproduce the issue. |
|
After further investigation it seems that the root cause it Could you tell me what exact version of Worklets do you need the patch for? |
Thank you! I need it for version 0.7.2 |
|
Here's a bandaid patch, you'll need to recompile the app as it changes the native code. Let me know if it works, then I'll know for sure what is the culprit here. |
The patch worked for me. |
|
Good. It might slightly increase the memory imprint as the callbacks from I'll have to think about an actual good solution to this problem. |
Details
This PR fixes the Sentry crash
(std::__ndk1::default_delete<T>::operator()[abi:ne180000])reported here. TheglobalMarkdownWorkletRuntimecould be accessed from both theJSandUIthreads, causing a data race, this PR adds a mutex to protect thisshared_ptr.Related Issues
Expensify/App#82146
Manual Tests
This issue is hard to reproduce, so please we need to verify that the input still works as before like typing, copy/pasting, and other basic interactions
Linked PRs