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

Possible memory leak #1223

Closed
lucaswitch opened this issue Dec 15, 2023 · 30 comments
Closed

Possible memory leak #1223

lucaswitch opened this issue Dec 15, 2023 · 30 comments
Labels
bug Something isn't working

Comments

@lucaswitch
Copy link

Bug Description

The iOS react-native application suddenly crashes when the user are consuming it. Not sure which it's the cause. When those crashes occurs, i can deal because happens usually it's a community, or invalid js call, which i can backtrace it using the stacktrace(somehow the problematic module is always on the stacktrace.), but in this case can't see which module caused it leaving me no choice but search help here since the crash happened on hermes engine.

Having a random issue using the 0.73 version of react-native.
Hermes enabled and new arch disabled.

  • [x ] Since it just happens on iOS as usual i always clean the project and then run pod install to install the latest deps.

Hermes version: Not sure which version, the 0.73 react-native bundled hermes version.
React Native: 0.73
OS: 17.1
Platform: arm64-v8a, armeabi-v7a

Also here is my react-native-info:

info Fetching system and libraries information...
System:
  OS: macOS 14.0
  CPU: (24) x64 Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz
  Memory: 54.28 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 10.1.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.11.27.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/opt/ruby/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.21
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /usr/local/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0
    wanted: "0.73"
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Full stacktrace:

OS Version: iOS 17.1 (23B92)
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP at 0x000000003e806ff0
Crashed Thread: 3

Application Specific Information:
natural >
KERN_INVALID_ADDRESS at 0x3e806ff0.

Thread 3 Crashed:
0   hermes                          0x10591bc94         hermes::vm::HadesGC::MarkWeakRootsAcceptor::acceptWeak
1   hermes                          0x105918188         hermes::vm::GCBase::markWeakRoots
2   hermes                          0x105917370         hermes::vm::HadesGC::completeMarking
3   hermes                          0x105916714         hermes::vm::HadesGC::incrementalCollect
4   hermes                          0x105919630         hermes::vm::HadesGC::yieldToOldGen
5   hermes                          0x1059164e4         hermes::vm::HadesGC::youngGenCollection
6   hermes                          0x105918c24         hermes::vm::HadesGC::allocSlow
7   hermes                          0x1058c4818         hermes::vm::GCBase::makeAVariable<T>
8   hermes                          0x1058c340c         hermes::vm::StringBuilder::createStringBuilder
9   hermes                          0x1058c3250         hermes::vm::StringPrimitive::concat
10  hermes                          0x1058a729c         hermes::vm::addOp_RJS
11  hermes                          0x105881284         hermes::vm::Interpreter::interpretFunction<T>
12  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
13  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
14  hermes                          0x10586ff84         hermes::vm::BoundFunction::_boundCall
15  hermes                          0x10587ce14         hermes::vm::Interpreter::handleCallSlowPath
16  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
17  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
18  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
19  hermes                          0x10586f060         hermes::vm::Callable::executeCall3
20  hermes                          0x10589dc48         hermes::vm::JSMapImpl<T>::forEach
21  hermes                          0x1058ef45c         hermes::vm::mapPrototypeForEach
22  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
23  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
24  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
25  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
26  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
27  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
28  hermes                          0x105902774         hermes::vm::functionPrototypeApply
29  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
30  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
31  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
32  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
33  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
34  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
35  hermes                          0x105902774         hermes::vm::functionPrototypeApply
36  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
37  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
38  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
39  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
40  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
41  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
42  hermes                          0x105902774         hermes::vm::functionPrototypeApply
43  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
44  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
45  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
46  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
47  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
48  hermes                          0x10586ff84         hermes::vm::BoundFunction::_boundCall
49  hermes                          0x10585ad6c         facebook::hermes::HermesRuntimeImpl::call
50  fitcheckpersonal                0x204951f5c         [inlined] facebook::jsi::RuntimeDecorator<T>::call (decorator.h:340)
51  fitcheckpersonal                0x204951f5c         facebook::jsi::WithRuntimeDecorator<T>::call (decorator.h:753)
52  fitcheckpersonal                0x204959864         [inlined] facebook::jsi::Function::call (jsi-inl.h:259)
53  fitcheckpersonal                0x204959864         [inlined] facebook::jsi::Function::call (jsi-inl.h:264)
54  fitcheckpersonal                0x204959864         facebook::jsi::Function::call<T> (jsi-inl.h:272)
55  fitcheckpersonal                0x2049596d0         [inlined] facebook::react::JSIExecutor::callFunction::lambda::operator() (JSIExecutor.cpp:258)
56  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
57  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
58  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__function::__alloc_func<T>::operator()[abi:v160006] (function.h:185)
59  fitcheckpersonal                0x2049596d0         std::__1::__function::__func<T>::operator() (function.h:356)
60  fitcheckpersonal                0x204787234         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
61  fitcheckpersonal                0x204787234         std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
62  fitcheckpersonal                0x2049569fc         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
63  fitcheckpersonal                0x2049569fc         [inlined] std::__1::function<T>::operator() (function.h:1156)
64  fitcheckpersonal                0x2049569fc         facebook::react::JSIExecutor::callFunction (JSIExecutor.cpp:256)
65  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
66  fitcheckpersonal                0x20494b02c         [inlined] std::__1::function<T>::operator() (function.h:1156)
67  fitcheckpersonal                0x20494b02c         [inlined] facebook::react::NativeToJsBridge::runOnExecutorQueue::lambda::operator() (NativeToJsBridge.cpp:308)
68  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
69  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
70  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__function::__alloc_func<T>::operator()[abi:v160006] (function.h:185)
71  fitcheckpersonal                0x20494b02c         std::__1::__function::__func<T>::operator() (function.h:356)
72  fitcheckpersonal                0x20478a56c         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
73  fitcheckpersonal                0x20478a56c         [inlined] std::__1::function<T>::operator() (function.h:1156)
74  fitcheckpersonal                0x20478a56c         facebook::react::tryAndReturnError (RCTCxxUtils.mm:73)
75  fitcheckpersonal                0x204795ef0         facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:68)
76  fitcheckpersonal                0x204795cfc         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
77  fitcheckpersonal                0x204795cfc         [inlined] std::__1::function<T>::operator() (function.h:1156)
78  fitcheckpersonal                0x204795cfc         facebook::react::RCTMessageThread::runAsync (RCTMessageThread.mm:44)
79  CoreFoundation                  0x30cfcd890         __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
80  CoreFoundation                  0x30cfcd7a4         __CFRunLoopDoBlocks
81  CoreFoundation                  0x30cfccc38         __CFRunLoopRun
82  CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
83  fitcheckpersonal                0x20477fa7c         +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:332)
84  Foundation                      0x30f1f7ff0         __NSThread__start__
85  libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 0
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   CoreFoundation                  0x30cfcdea0         __CFRunLoopServiceMachPort
5   CoreFoundation                  0x30cfcc768         __CFRunLoopRun
6   CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
7   HIToolbox                       0x321b10444         RunCurrentEventLoopInMode
8   HIToolbox                       0x321b10280         ReceiveNextEventCommon
9   HIToolbox                       0x321b0ffd8         _BlockUntilNextEventMatchingListInModeWithFilter
10  AppKit                          0x313fc3c50         _DPSNextEvent
11  AppKit                          0x314799eb8         -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
12  AppKit                          0x313fb70fc         -[NSApplication run]
13  AppKit                          0x313f8e3c8         NSApplicationMain
14  AppKit                          0x3141e123c         _NSApplicationMainWithInfoDictionary
15  UIKitMacHelper                  0x33e7a2d88         UINSApplicationMain
16  UIKitCore                       0x369ac3938         UIApplicationMain
17  fitcheckpersonal                0x204690034         main (main.m:8)
18  <unknown>                       0x18c6dd0e0         <redacted>

Thread 1 name: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   CoreFoundation                  0x30cfcdea0         __CFRunLoopServiceMachPort
5   CoreFoundation                  0x30cfcc768         __CFRunLoopRun
6   CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
7   Foundation                      0x30f1fea74         -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8   Foundation                      0x30f2733ec         -[NSRunLoop(NSRunLoop) runUntilDate:]
9   UIKitCore                       0x369ac4d04         -[UIEventFetcher threadMain]
10  Foundation                      0x30f1f7ff0         __NSThread__start__
11  libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 2 name: com.apple.NSEventThread
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   CoreFoundation                  0x30cfcdea0         __CFRunLoopServiceMachPort
5   CoreFoundation                  0x30cfcc768         __CFRunLoopRun
6   CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
7   AppKit                          0x3140ed400         _NSEventThread
8   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 3 name: com.facebook.react.JavaScript Crashed:
0   hermes                          0x10591bc94         hermes::vm::HadesGC::MarkWeakRootsAcceptor::acceptWeak
1   hermes                          0x105918188         hermes::vm::GCBase::markWeakRoots
2   hermes                          0x105917370         hermes::vm::HadesGC::completeMarking
3   hermes                          0x105916714         hermes::vm::HadesGC::incrementalCollect
4   hermes                          0x105919630         hermes::vm::HadesGC::yieldToOldGen
5   hermes                          0x1059164e4         hermes::vm::HadesGC::youngGenCollection
6   hermes                          0x105918c24         hermes::vm::HadesGC::allocSlow
7   hermes                          0x1058c4818         hermes::vm::GCBase::makeAVariable<T>
8   hermes                          0x1058c340c         hermes::vm::StringBuilder::createStringBuilder
9   hermes                          0x1058c3250         hermes::vm::StringPrimitive::concat
10  hermes                          0x1058a729c         hermes::vm::addOp_RJS
11  hermes                          0x105881284         hermes::vm::Interpreter::interpretFunction<T>
12  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
13  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
14  hermes                          0x10586ff84         hermes::vm::BoundFunction::_boundCall
15  hermes                          0x10587ce14         hermes::vm::Interpreter::handleCallSlowPath
16  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
17  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
18  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
19  hermes                          0x10586f060         hermes::vm::Callable::executeCall3
20  hermes                          0x10589dc48         hermes::vm::JSMapImpl<T>::forEach
21  hermes                          0x1058ef45c         hermes::vm::mapPrototypeForEach
22  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
23  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
24  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
25  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
26  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
27  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
28  hermes                          0x105902774         hermes::vm::functionPrototypeApply
29  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
30  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
31  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
32  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
33  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
34  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
35  hermes                          0x105902774         hermes::vm::functionPrototypeApply
36  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
37  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
38  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
39  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
40  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
41  hermes                          0x10586f5a0         hermes::vm::Callable::executeCall
42  hermes                          0x105902774         hermes::vm::functionPrototypeApply
43  hermes                          0x10587029c         hermes::vm::NativeFunction::_nativeCall
44  hermes                          0x10587ce04         hermes::vm::Interpreter::handleCallSlowPath
45  hermes                          0x10587e60c         hermes::vm::Interpreter::interpretFunction<T>
46  hermes                          0x10587ddfc         hermes::vm::Runtime::interpretFunctionImpl
47  hermes                          0x105870394         hermes::vm::JSFunction::_callImpl
48  hermes                          0x10586ff84         hermes::vm::BoundFunction::_boundCall
49  hermes                          0x10585ad6c         facebook::hermes::HermesRuntimeImpl::call
50  fitcheckpersonal                0x204951f5c         [inlined] facebook::jsi::RuntimeDecorator<T>::call (decorator.h:340)
51  fitcheckpersonal                0x204951f5c         facebook::jsi::WithRuntimeDecorator<T>::call (decorator.h:753)
52  fitcheckpersonal                0x204959864         [inlined] facebook::jsi::Function::call (jsi-inl.h:259)
53  fitcheckpersonal                0x204959864         [inlined] facebook::jsi::Function::call (jsi-inl.h:264)
54  fitcheckpersonal                0x204959864         facebook::jsi::Function::call<T> (jsi-inl.h:272)
55  fitcheckpersonal                0x2049596d0         [inlined] facebook::react::JSIExecutor::callFunction::lambda::operator() (JSIExecutor.cpp:258)
56  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
57  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
58  fitcheckpersonal                0x2049596d0         [inlined] std::__1::__function::__alloc_func<T>::operator()[abi:v160006] (function.h:185)
59  fitcheckpersonal                0x2049596d0         std::__1::__function::__func<T>::operator() (function.h:356)
60  fitcheckpersonal                0x204787234         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
61  fitcheckpersonal                0x204787234         std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
62  fitcheckpersonal                0x2049569fc         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
63  fitcheckpersonal                0x2049569fc         [inlined] std::__1::function<T>::operator() (function.h:1156)
64  fitcheckpersonal                0x2049569fc         facebook::react::JSIExecutor::callFunction (JSIExecutor.cpp:256)
65  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
66  fitcheckpersonal                0x20494b02c         [inlined] std::__1::function<T>::operator() (function.h:1156)
67  fitcheckpersonal                0x20494b02c         [inlined] facebook::react::NativeToJsBridge::runOnExecutorQueue::lambda::operator() (NativeToJsBridge.cpp:308)
68  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__invoke[abi:v160006]<T> (invoke.h:394)
69  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__invoke_void_return_wrapper<T>::__call<T> (invoke.h:487)
70  fitcheckpersonal                0x20494b02c         [inlined] std::__1::__function::__alloc_func<T>::operator()[abi:v160006] (function.h:185)
71  fitcheckpersonal                0x20494b02c         std::__1::__function::__func<T>::operator() (function.h:356)
72  fitcheckpersonal                0x20478a56c         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
73  fitcheckpersonal                0x20478a56c         [inlined] std::__1::function<T>::operator() (function.h:1156)
74  fitcheckpersonal                0x20478a56c         facebook::react::tryAndReturnError (RCTCxxUtils.mm:73)
75  fitcheckpersonal                0x204795ef0         facebook::react::RCTMessageThread::tryFunc (RCTMessageThread.mm:68)
76  fitcheckpersonal                0x204795cfc         [inlined] std::__1::__function::__value_func<T>::operator()[abi:v160006] (function.h:510)
77  fitcheckpersonal                0x204795cfc         [inlined] std::__1::function<T>::operator() (function.h:1156)
78  fitcheckpersonal                0x204795cfc         facebook::react::RCTMessageThread::runAsync (RCTMessageThread.mm:44)
79  CoreFoundation                  0x30cfcd890         __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
80  CoreFoundation                  0x30cfcd7a4         __CFRunLoopDoBlocks
81  CoreFoundation                  0x30cfccc38         __CFRunLoopRun
82  CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
83  fitcheckpersonal                0x20477fa7c         +[RCTCxxBridge runRunLoop] (RCTCxxBridge.mm:332)
84  Foundation                      0x30f1f7ff0         __NSThread__start__
85  libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 4 name: hades
0   libsystem_kernel.dylib          0x30ce130ac         __psynch_cvwait
1   libsystem_pthread.dylib         0x30ce8b5f8         _pthread_cond_wait
2   libc++.1.dylib                  0x30ccd54d8         std::__1::condition_variable::wait
3   hermes                          0x10591c104         hermes::vm::HadesGC::Executor::worker
4   hermes                          0x10591bfa4         std::__1::__thread_proxy[abi:v15006]<T>
5   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 5 name: com.apple.CoreMotion.MotionThread
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   CoreFoundation                  0x30cfcdea0         __CFRunLoopServiceMachPort
5   CoreFoundation                  0x30cfcc768         __CFRunLoopRun
6   CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
7   CoreFoundation                  0x30d049990         CFRunLoopRun
8   CoreMotion                      0x354239278         CLClientCreateIso6709Notation
9   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 6 name: caulk.messenger.shared:17
0   libsystem_kernel.dylib          0x30ce0f830         semaphore_wait_trap
1   caulk                           0x32153868c         caulk::semaphore::timed_wait
2   caulk                           0x321538540         caulk::concurrent::details::worker_thread::run
3   caulk                           0x321538240         caulk::thread_proxy<T>
4   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 7 name: caulk.messenger.shared:high
0   libsystem_kernel.dylib          0x30ce0f830         semaphore_wait_trap
1   caulk                           0x32153868c         caulk::semaphore::timed_wait
2   caulk                           0x321538540         caulk::concurrent::details::worker_thread::run
3   caulk                           0x321538240         caulk::thread_proxy<T>
4   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 8
0   libsystem_kernel.dylib          0x30ce12ea8         __semwait_signal
1   libsystem_c.dylib               0x30cbd12f4         nanosleep
2   libsystem_c.dylib               0x30cbda0b8         sleep
3   fitcheckpersonal                0x204985e94         monitorCachedData (SentryCrashCachedData.c:145)
4   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 9 name: SentryCrash Exception Handler (Secondary)
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   fitcheckpersonal                0x204991bdc         handleExceptions (SentryCrashMonitor_MachException.c:314)
5   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 11 name: io.sentry.app-hang-tracker
0   libsystem_kernel.dylib          0x30ce12ea8         __semwait_signal
1   libsystem_c.dylib               0x30cbd12f4         nanosleep
2   Foundation                      0x30f2763a0         +[NSThread sleepForTimeInterval:]
3   fitcheckpersonal                0x204975520         -[SentryANRTracker detectANRs] (SentryANRTracker.m:105)
4   Foundation                      0x30f1f7ff0         __NSThread__start__
5   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 12 name: caulk::deferred_logger
0   libsystem_kernel.dylib          0x30ce0f830         semaphore_wait_trap
1   caulk                           0x32153868c         caulk::semaphore::timed_wait
2   caulk                           0x321538540         caulk::concurrent::details::worker_thread::run
3   caulk                           0x321538240         caulk::thread_proxy<T>
4   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 13 name: hades
0   libsystem_kernel.dylib          0x30ce130ac         __psynch_cvwait
1   libsystem_pthread.dylib         0x30ce8b5f8         _pthread_cond_wait
2   libc++.1.dylib                  0x30ccd54d8         std::__1::condition_variable::wait
3   hermes                          0x10591c104         hermes::vm::HadesGC::Executor::worker
4   hermes                          0x10591bfa4         std::__1::__thread_proxy[abi:v15006]<T>
5   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 14 name: AQConverterThread
0   libsystem_kernel.dylib          0x30ce130ac         __psynch_cvwait
1   libsystem_pthread.dylib         0x30ce8b5f8         _pthread_cond_wait
2   libAudioToolboxUtility.dylib    0x32a63ace0         CADeprecated::CAGuard::Wait
3   AudioToolbox                    0x32cbf43a0         AQConverterManager::AQConverterThread::ConverterThreadEntry
4   libAudioToolboxUtility.dylib    0x32a6171ac         CADeprecated::CAPThread::Entry
5   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 15 name: com.apple.NSURLConnectionLoader
0   libsystem_kernel.dylib          0x30ce0f8b4         mach_msg2_trap
1   libsystem_kernel.dylib          0x30ce21d2c         mach_msg2_internal
2   libsystem_kernel.dylib          0x30ce184ec         mach_msg_overwrite
3   libsystem_kernel.dylib          0x30ce0fc34         mach_msg
4   CoreFoundation                  0x30cfcdea0         __CFRunLoopServiceMachPort
5   CoreFoundation                  0x30cfcc768         __CFRunLoopRun
6   CoreFoundation                  0x30cfcbc58         CFRunLoopRunSpecific
7   CFNetwork                       0x3175bb394         _CFURLStorageSessionDisableCache
8   Foundation                      0x30f1f7ff0         __NSThread__start__
9   libsystem_pthread.dylib         0x30ce8b030         _pthread_start

Thread 16
0   libsystem_kernel.dylib          0x30ce11564         __workq_kernreturn
1   libsystem_pthread.dylib         0x30ce8715c         _pthread_wqthread

Thread 17
0   libsystem_kernel.dylib          0x30ce11564         __workq_kernreturn
1   libsystem_pthread.dylib         0x30ce8715c         _pthread_wqthread

Thread 18
0   libsystem_kernel.dylib          0x30ce11564         __workq_kernreturn
1   libsystem_pthread.dylib         0x30ce8715c         _pthread_wqthread

Thread 3 crashed with ARM Thread State (64-bit):
    x0: 0x000000016bbcf6c8   x1: 0x0000000143813a00   x2: 0x000000016bbcf6c8   x3: 0x0000000146ada200
    x4: 0x0000000000000002   x5: 0x0000000146ada200   x6: 0x0000000000000400   x7: 0x00000000000b0000
    x8: 0x0000000000017f93   x9: 0x000000003e804000  x10: 0x0000000000002ff0  x11: 0x000000014406b200
   x12: 0x0000000146ad8000  x13: 0x0000000000003fff  x14: 0x0000000000001690  x15: 0x00000000ffff7dff
   x16: 0x000000018ca18c9c  x17: 0x00000001ebbf8198  x18: 0x0000000000000000  x19: 0x000000016bbcf6c8
   x20: 0x0000000143813a00  x21: 0x000000014413d5e0  x22: 0x000000014416dd70  x23: 0x0000000146832ea0
   x24: 0x0000000146834940  x25: 0x0000000000000000  x26: 0x00000000000097df  x27: 0x00000000003de7b8
   x28: 0x0000000000000001   fp: 0x000000016bbcf6b0   lr: 0x000000010591818c   sp: 0x000000016bbcf690
    pc: 0x000000010591bc94 cpsr: 0x0000000080001000



EOF

code example:

The Expected Behavior

Not to crash.

@lucaswitch lucaswitch added the bug Something isn't working label Dec 15, 2023
@lucaswitch
Copy link
Author

After running the application for 13 hours this crash is ocurring.
Screenshot 2023-12-29 at 09 49 48

@lucaswitch
Copy link
Author

Screenshot 2023-12-29 at 09 54 04
Also can see this on the stack trace, not sure how to reproduce it yet cause i can't find the actual cause of the crash on the js code.

@tmikov
Copy link
Contributor

tmikov commented Dec 29, 2023

The error in the previous screenshot seems to be out of memory?

@lucaswitch
Copy link
Author

@tmikov yes, also the cpu goes all the way up when the crash begins.

@tmikov
Copy link
Contributor

tmikov commented Dec 29, 2023

Everybody is on a break now, but we will take a more serious look after the holidays.

@lucaswitch
Copy link
Author

@tmikov thank you for replying and happy holidays!

@lucaswitch
Copy link
Author

Any updates on this stacktrace?
@tmikov

@lucaswitch lucaswitch changed the title Random iOS crash on hermes engine. Possible memory leak Jan 8, 2024
@neildhar
Copy link
Contributor

Hey @lucaswitch, we'd need more information, like a minimal repro to offer more insight here. It looks like you may be running into two separate problems, the first is a crash somewhere in the GC, and the second is an OOM.

The OOM is likely caused by a large number of allocations, and you can try debugging it by connecting to the application in DevTools and taking a heap snapshot or an allocation timeline profile. That should help you pin down where the allocations are coming from. It is also worth monitoring the runtime's reporting memory consumption by calling HermesInternal.getInstrumentedStats() in JS.

The crash is trickier and may indicate a bug in Hermes, unless Hermes is being used incorrectly (e.g. from multiple threads simultaneously). Are you able to share a minimised JS repro that results in the crash?

@lucaswitch
Copy link
Author

Thank you for replying, I'm also debugging for possible causes that could create the OOM or any kind of over memory/cpu usage.
I will try to create a reproducer once i figure this out. The problem is i can't figure out where it is and sometimes it needs a couple hours of use to reproduce the crash.

@lucaswitch
Copy link
Author

lucaswitch commented Jan 17, 2024

@neildhar Does this getInstrumentedStats looks normal:

{"js_VMExperiments": 0, "js_allocatedBytes": 26423128, "js_gcCPUTime": 0.123, "js_gcTime": 0.4050000000000003, "js_heapSize": 33554432, "js_mallocSizeEstimate": 0, "js_markStackOverflows": 0, "js_numGCs": 224, "js_totalAllocatedBytes": 903991048, "js_vaSize": 33554432}

js_totalAllocatedBytes looks too big but not sure if it's to be that way on debug mode.

Is there a documentation about the getInstrumentedStats attributes meaning?

@tmikov
Copy link
Contributor

tmikov commented Jan 17, 2024

32MB heap, looks totally normal.

@lucaswitch
Copy link
Author

lucaswitch commented Jan 18, 2024

So i think the oom is solved(we did a full refactor of the app), but the crash sadly persists the same.

Also now i'm keeping eye on the getInstrumentedStats all the time and seems normal(only js_totalAllocatedBytes gets quite big)

I will consider that some module could be messing up the runtime for now.
Is there some kind of object that could provide which native modules are using jsi at the moment of a crash?

I'm looking some variables at the moment of the crash to indicate which module could be causing this crash then i can take a deeper look at It. And then make a repro(or remove it).

Looking after those stacktrace i could not find enough information that could lead a third party module.

The stacktrace changes a little bit between crashes except on LINE facebook::jsi::RuntimeDecorator::call (decorator.h:340) and above.
I can always see the variables and debug into it, and thats what ive doing.

What we know at this moment:
The methodId and moduleId at the moment of the crash are always between these values:

moduleId: JSTimers and methodId callTimers

moduleId RCTEventEmitter and methodId ReceiveTouches

moduleId RCTEventEmitter and methodId emit

Can you provide some help to find It on how to find which module it's being executed?

@lucaswitch
Copy link
Author

lucaswitch commented Jan 18, 2024

The issue also only happens on iOS 16 and 17. Our app works with user health monitoring so we had to shutdown the iOS version to solve that issue due to thousands of this crash.

@tmikov
Copy link
Contributor

tmikov commented Jan 18, 2024

@lucaswitch

Is there a documentation about the getInstrumentedStats attributes meaning?

@neildhar can probably provide more detail, but most of the fields are documented here:

struct HeapInfo {

The other fields just show the total number of GCs and how much time in milliseconds they took.

@lucaswitch
Copy link
Author

@lucaswitch

Is there a documentation about the getInstrumentedStats attributes meaning?

@neildhar can probably provide more detail, but most of the fields are documented here:

struct HeapInfo {

The other fields just show the total number of GCs and how much time in milliseconds they took.

Thank you this header file contains all that i need about the getInstrumentedStats.

Can you provide some help which files contains the information about which react-native native module is calling the jsi environment?

@lucaswitch
Copy link
Author

Found something! This code from watermelon database heavily access the jsi runtime.
But i don't think there is any issue with that since it does not open another thread.
Here is the code:

#include "Database.h"
#include "DatabasePlatform.h"
#include "JSIHelpers.h"

namespace watermelondb {

using platform::consoleError;
using platform::consoleLog;

void Database::install(jsi::Runtime *runtime) {
    jsi::Runtime &rt = *runtime;
    auto globalObject = rt.global();
    createMethod(rt, globalObject, "nativeWatermelonCreateAdapter", 2, [runtime](jsi::Runtime &rt, const jsi::Value *args) {
        std::string dbPath = args[0].getString(rt).utf8(rt);
        bool usesExclusiveLocking = args[1].getBool();

        jsi::Object adapter(rt);

        std::shared_ptr<Database> database = std::make_shared<Database>(runtime, dbPath, usesExclusiveLocking);
        adapter.setProperty(rt, "database", jsi::Object::createFromHostObject(rt, database));

        // FIXME: Important hack!
        // Without any hacks, JSI Watermelon crashes on Android/Hermes on app reload in development:
        // (This doesn't happen on iOS/JSC)
        //   abort 0x00007d0bd27cff2f
        //   __fortify_fatal(char const*, ...) 0x00007d0bd27d20c1
        //   HandleUsingDestroyedMutex(pthread_mutex_t*, char const*) 0x00007d0bd283b020
        //   pthread_mutex_lock 0x00007d0bd283aef4
        //   pthreadMutexEnter sqlite3.c:26320
        //   sqlite3_mutex_enter sqlite3.c:25775
        //   sqlite3_next_stmt sqlite3.c:84221
        //   watermelondb::SqliteDb::~SqliteDb() Sqlite.cpp:57
        // It appears that the Unix thread on which Database is set up is already destroyed by the
        // time destructor is called. AFAIU destructors on objects that are managed by JSI runtime
        // *should* be safe in this respect, but maybe they're not/there's a bug...
        //
        // For future debuggers, the flow goes like this:
        //  - ReactInstanceManager.runCreateReactContextOnNewThread()
        //       this sets up new instance
        //  - ReactInstanceManager.tearDownReactContext()
        //  - ReactContext.destroy()
        //  - CatalystInstanceImpl.destroy()
        //       this notifies listeners that the app is about to be destroyed
        //  - mHybridData.resetNative()
        //  - ~CatalystInstanceImpl()
        //  - ~Instance()
        //  - NativeToJSBridge.destroy()
        //  - m_executor = nullptr
        //  - ~Runtime()
        //  - ...
        //  - ~Database()
        //
        // First attempt to work around this issue was by disabling sqlite3's threadsafety (which caused
        // pthread apis to be called, leading to a crash), since we're only using it from one thread
        // but predictably that caused new issues.
        // When using headless JS, this issue would occur:
        //    Failed to get a row for query - sqlite error 11 (database disk image is malformed)
        // (Not exactly sure why, seems like headless JS reuses the same catalyst instance...)
        //
        // Current workaround is to tap into CatalystInstanceImpl.destroy() to destroy the database
        // before it's destructed via normal C++ rules. There's no clean API for our JSI setup, so
        // we route via NativeModuleRegistry onCatalystInstanceDestroy -> DatabaseBridge ->
        // WatermelonJSI via reflection (and switch to the currect thread - important!) and then to
        // individual Database objects via this listener callback. It's ugly, but should work.
        //
        // 2023 update: Check if the above is still true, given https://github.com/Nozbe/WatermelonDB/issues/1474
        // showed that the true cause of the pthread_mutex_lock crash is something else.
        // On the other hand, it's still true that invalidation happens asynchronously and could happen
        // after new bridge is already set up, which could cause locking issues (and a case was found on iOS where
        // this does happen)
        std::weak_ptr<Database> weakDatabase = database;
        platform::onDestroy([weakDatabase]() {
            if (auto databaseToDestroy = weakDatabase.lock()) {
                consoleLog("Destroying database due to RCTBridge invalidation");
                databaseToDestroy->destroy();
            }
        });

        createMethod(rt, adapter, "initialize", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            jsi::String dbName = args[0].getString(rt);
            int expectedVersion = (int)args[1].getNumber();

            int databaseVersion = database->getUserVersion();

            jsi::Object response(rt);

            if (databaseVersion == expectedVersion) {
                database->initialized_ = true;
                response.setProperty(rt, "code", "ok");
            } else if (databaseVersion == 0) {
                response.setProperty(rt, "code", "schema_needed");
            } else if (databaseVersion < expectedVersion) {
                response.setProperty(rt, "code", "migrations_needed");
                response.setProperty(rt, "databaseVersion", databaseVersion);
            } else {
                consoleLog("Database has newer version (" + std::to_string(databaseVersion) +
                           ") than what the app supports (" + std::to_string(expectedVersion) + "). Will reset database.");
                response.setProperty(rt, "code", "schema_needed");
            }

            return response;
        });
        createMethod(rt, adapter, "setUpWithSchema", 3, [database](jsi::Runtime &rt, const jsi::Value *args) {
            jsi::String dbName = args[0].getString(rt);
            jsi::String schema = args[1].getString(rt);
            int schemaVersion = (int)args[2].getNumber();

            try {
                database->unsafeResetDatabase(schema, schemaVersion);
            } catch (const std::exception &ex) {
                consoleError("Failed to set up the database correctly - " + std::string(ex.what()));
                std::abort();
            }

            database->initialized_ = true;
            return jsi::Value::undefined();
        });
        createMethod(rt, adapter, "setUpWithMigrations", 4, [database](jsi::Runtime &rt, const jsi::Value *args) {
            jsi::String dbName = args[0].getString(rt);
            jsi::String migrationSchema = args[1].getString(rt);
            int fromVersion = (int)args[2].getNumber();
            int toVersion = (int)args[3].getNumber();

            try {
                database->migrate(migrationSchema, fromVersion, toVersion);
            } catch (const std::exception &ex) {
                consoleError("Failed to migrate the database correctly - " + std::string(ex.what()));
                return makeError(rt, ex.what());
            }

            database->initialized_ = true;
            return jsi::Value::undefined();
        });
        createMethod(rt, adapter, "find", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String tableName = args[0].getString(rt);
            jsi::String id = args[1].getString(rt);
            return database->find(tableName, id);
        });
        createMethod(rt, adapter, "query", 3, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String tableName = args[0].getString(rt);
            jsi::String sql = args[1].getString(rt);
            jsi::Array arguments = args[2].getObject(rt).getArray(rt);
            return database->query(tableName, sql, arguments);
        });
        createMethod(rt, adapter, "queryAsArray", 3, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String tableName = args[0].getString(rt);
            jsi::String sql = args[1].getString(rt);
            jsi::Array arguments = args[2].getObject(rt).getArray(rt);
            return database->queryAsArray(tableName, sql, arguments);
        });
        createMethod(rt, adapter, "queryIds", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String sql = args[0].getString(rt);
            jsi::Array arguments = args[1].getObject(rt).getArray(rt);
            return database->queryIds(sql, arguments);
        });
        createMethod(rt, adapter, "unsafeQueryRaw", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String sql = args[0].getString(rt);
            jsi::Array arguments = args[1].getObject(rt).getArray(rt);
            return database->unsafeQueryRaw(sql, arguments);
        });
        createMethod(rt, adapter, "count", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String sql = args[0].getString(rt);
            jsi::Array arguments = args[1].getObject(rt).getArray(rt);
            return database->count(sql, arguments);
        });
        createMethod(rt, adapter, "batch", 1, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::Array operations = args[0].getObject(rt).getArray(rt);
            database->batch(operations);
            return jsi::Value::undefined();
        });
        createMethod(rt, adapter, "batchJSON", 1, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            database->batchJSON(args[0].getString(rt));
            return jsi::Value::undefined();
        });
        createMethod(rt, adapter, "getLocal", 1, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String key = args[0].getString(rt);
            return database->getLocal(key);
        });
        createMethod(rt, adapter, "unsafeLoadFromSync", 4, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            auto jsonId = (int) args[0].getNumber();
            auto schema = args[1].getObject(rt);
            auto preamble = args[2].getString(rt).utf8(rt);
            auto postamble = args[3].getString(rt).utf8(rt);
            return database->unsafeLoadFromSync(jsonId, schema, preamble, postamble);
        });
        createMethod(rt, adapter, "unsafeExecuteMultiple", 1, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            auto sqlString = args[0].getString(rt).utf8(rt);
            database->executeMultiple(sqlString);
            return jsi::Value::undefined();
        });
        createMethod(rt, adapter, "unsafeResetDatabase", 2, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            jsi::String schema = args[0].getString(rt);
            int schemaVersion = (int)args[1].getNumber();

            try {
                database->unsafeResetDatabase(schema, schemaVersion);
                return jsi::Value::undefined();
            } catch (const std::exception &ex) {
                consoleError("Failed to reset database correctly - " + std::string(ex.what()));
                // Partially reset database is likely corrupted, so it's probably less bad to crash
                std::abort();
            }
        });
        createMethod(rt, adapter, "unsafeClose", 0, [database](jsi::Runtime &rt, const jsi::Value *args) {
            assert(database->initialized_);
            database->destroy();
            database->initialized_ = false;
            return jsi::Value::undefined();
        });

        return adapter;
    });

    // TODO: Use the onMemoryAlert hook!
}


} // namespace watermelondb

@neildhar
Copy link
Contributor

which react-native native module is calling the jsi environment

That would fall outside Hermes unfortunately. It is possible that RN has some logging that logs transitions into native code from JS, but we can't provide much input there.

Your best bet may be to attach a debugger and set breakpoints on entry into the Hermes runtime to determine if anything is potentially corrupting runtime state.

@lucaswitch
Copy link
Author

lucaswitch commented Jan 18, 2024

Can you provide some interesting points on React-jsi directory to place the debugger on?
Having a hard time to where to place it

@tmikov
Copy link
Contributor

tmikov commented Jan 19, 2024

This is probably a good place, you should get a hit whenever native calls into JavaScript:

jsi::Value HermesRuntimeImpl::call(

@lucaswitch
Copy link
Author

Screenshot 2024-01-22 at 11 30 53
Is it normal to have this quantity of leak warnings on debug mode?

@neildhar
Copy link
Contributor

@lucaswitch According to Apple's documentation it looks like the leak detector works by scanning the application memory for pointers to regions that were allocated with malloc.

The behaviour you're seeing is expected, since we recently made a change to how the pointers are encoded in the heap, which would result in the leaks tool not being able to find them. However, this isn't a real leak, and Hermes should still release the memory whenever the ArrayBuffer is garbage collected.

@lucaswitch
Copy link
Author

Thank you for the fast response! Ok i will keep looking around on jsi modules.

@lucaswitch
Copy link
Author

The stacktrace changed a bit. Removed a lot of the application deps.
Screenshot 2024-01-23 at 14 27 30

@neildhar
Copy link
Contributor

It is possible that the issue you're observing is a known leak in WeakMap, which was discussed in #1147 and fixed in e7b2abe.

Could you try calling gc() from JS periodically and see if that brings the memory consumption under control?

@lucaswitch
Copy link
Author

Done! @neildhar. As the #1147 i placed it every 100ms.
Screenshot 2024-01-23 at 15 28 19

@lucaswitch
Copy link
Author

lucaswitch commented Jan 23, 2024

Another crash, also i can see that the Module being called is the JSTimers.
Screenshot 2024-01-23 at 15 37 00
Screenshot 2024-01-23 at 15 37 14
Screenshot 2024-01-23 at 15 38 09
Screenshot 2024-01-23 at 15 44 47

@lucaswitch
Copy link
Author

Also i figure out that this is the current third party modules accessing the jsi functions.

image

@tmikov
Copy link
Contributor

tmikov commented Jan 24, 2024

@lucaswitch the top of the stack looks a deadlock exception thrown by the sampling profiler mutex. Very interesting. Can we see the message of that exception?

@lucaswitch
Copy link
Author

lucaswitch commented Jan 24, 2024

Here is another one maybe related to #1203.
Also because our app uses redux-saga it relies heavily on generator functions. I can see on the stacktrace some breadcrumbs that could be that: hermes::vm::GeneratorInnerFunction

Also i was not able to get the exception pointer value...

Screenshot 2024-01-24 at 09 54 02
Screenshot 2024-01-24 at 10 04 35
Screenshot 2024-01-24 at 10 05 51
Screenshot 2024-01-24 at 10 17 21

@lucaswitch
Copy link
Author

lucaswitch commented Jan 31, 2024

Solved! Closing as this issue is not a hermes engine issue.
It was a private react-native module with c++ responsible for doing fast fourrier transform that was causing the issue(maybe some wrong offset access or any kind o dynamic resource allocation).
After a full rewrite of this module in plain javascript the crash was gone.

Thank you for all the support on this issue. @tmikov @neildhar
Very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants