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

[JSI] HermesRuntimeImpl::call: Unable to call function: stack overflow #587

Closed
1 task done
mrousavy opened this issue Sep 3, 2021 · 7 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@mrousavy
Copy link
Contributor

mrousavy commented Sep 3, 2021

Bug Description

I am trying to create a new host function and install it in the JSI runtime's global object, but everytime I try to do that, my app crashes (SIGABRT).

  • I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.7.0
React Native version (if any): 0.64.0
OS version (if any):
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a

Steps To Reproduce

  1. Create JSI HostFunction
  2. Install to jsi::Runtime's global object
  3. See crash

code example:

void install(jsi::Runtime& jsiRuntime) {
    __android_log_print(ANDROID_LOG_INFO, "YEEET", "%s", "installing MMKV creator...");

    // MMKV.createNewInstance()
    auto mmkvCreateNewInstance = jsi::Function::createFromHostFunction(jsiRuntime,
                                                                       jsi::PropNameID::forAscii(jsiRuntime, "mmkvCreateNewInstance"),
                                                                       0,
                                                                       [](jsi::Runtime& runtime,
                                                                          const jsi::Value& thisValue,
                                                                          const jsi::Value* arguments,
                                                                          size_t count) -> jsi::Value {
                                                                         if (count != 1) {
                                                                             throw jsi::JSError(runtime, "MMKV.createNewInstance(..) expects one argument (object)!");
                                                                         }
                                                                         __android_log_print(ANDROID_LOG_INFO, "YEEET", "%s", "Creating new instance..");
                                                                         jsi::Object config = arguments[0].asObject(runtime);

                                                                         std::string instanceId = getPropertyAsStringOrNilFromObject(config, "id", runtime);
                                                                         std::string path = getPropertyAsStringOrNilFromObject(config, "path", runtime);
                                                                         std::string encryptionKey = getPropertyAsStringOrNilFromObject(config, "encryptionKey", runtime);

                                                                         __android_log_print(ANDROID_LOG_INFO, "YEEET", "%s", "Props gotten ");

                                                                         auto instance = std::make_shared<MmkvHostObject>(instanceId, path, encryptionKey);
                                                                         __android_log_print(ANDROID_LOG_INFO, "YEEET", "%s", "Instance created!");
                                                                         return jsi::Object::createFromHostObject(runtime, instance);
                                                                       });
    jsiRuntime.global().setProperty(jsiRuntime, "mmkvCreateNewInstance", mmkvCreateNewInstance);

    __android_log_print(ANDROID_LOG_INFO, "YEEET", "%s", "Installed MMKV creator!");
}

extern "C"
JNIEXPORT void JNICALL
Java_com_reactnativemmkv_MmkvModule_nativeInstall(JNIEnv *env, jobject clazz, jlong jsiPtr, jstring path) {
    auto runtime = reinterpret_cast<jsi::Runtime*>(jsiPtr);
    if (runtime) {
        install(*runtime);
    }
}

Full code in mrousavy/react-native-mmkv (feat/mmkv-host-object branch)

The Expected Behavior

I expect the function to be installed without problems.

The Android Logcat output:

2021-09-03 14:59:52.099 27208-27254/com.example.reactnativemmkv I/YEEET: installing MMKV creator...
2021-09-03 14:59:52.099 27208-27254/com.example.reactnativemmkv I/HermesVM: HermesRuntimeImpl::call: Unable to call function: stack overflow
2021-09-03 14:59:52.100 27208-27254/com.example.reactnativemmkv A/libc: /buildbot/src/googleplex-android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type facebook::jsi::JSINativeException: HermesRuntimeImpl::call: Unable to call function: stack overflow" failed
2021-09-03 14:59:52.100 27208-27254/com.example.reactnativemmkv A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 27254 (create_react_co), pid 27208 (reactnativemmkv)
2021-09-03 14:59:52.134 27264-27264/? I/crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
2021-09-03 14:59:52.135 1909-1909/? I//system/bin/tombstoned: received crash request for pid 27254
2021-09-03 14:59:52.135 27264-27264/? I/crash_dump32: performing dump of process 27208 (target tid = 27254)
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys'
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: Revision: '0'
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: ABI: 'x86'
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: Timestamp: 2021-09-03 14:59:52+0200
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: pid: 27208, tid: 27254, name: create_react_co  >>> com.example.reactnativemmkv <<<
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: uid: 10136
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG: Abort message: '/buildbot/src/googleplex-android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type facebook::jsi::JSINativeException: HermesRuntimeImpl::call: Unable to call function: stack overflow" failed'
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG:     eax 00000000  ebx 00006a48  ecx 00006a76  edx 00000006
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG:     edi e7c4633e  esi bbd5c850
2021-09-03 14:59:52.139 27264-27264/? A/DEBUG:     ebp eab88ad0  esp bbd5c7f8  eip eab88ad9
2021-09-03 14:59:52.180 27264-27264/? A/DEBUG: backtrace:
2021-09-03 14:59:52.180 27264-27264/? A/DEBUG:       #00 pc 00000ad9  [vdso] (__kernel_vsyscall+9)
2021-09-03 14:59:52.180 27264-27264/? A/DEBUG:       #01 pc 00092328  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #02 pc 000ad651  /apex/com.android.runtime/lib/bionic/libc.so (abort+193) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #03 pc 000adb88  /apex/com.android.runtime/lib/bionic/libc.so (__assert2+56) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #04 pc 0009a874  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libc++_shared.so (BuildId: e17c5af931f83c79fe858d7c19c030d4492104f4)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #05 pc 0009aace  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libc++_shared.so (BuildId: e17c5af931f83c79fe858d7c19c030d4492104f4)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #06 pc 000b2789  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libc++_shared.so (BuildId: e17c5af931f83c79fe858d7c19c030d4492104f4)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #07 pc 000b1cbe  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libc++_shared.so (BuildId: e17c5af931f83c79fe858d7c19c030d4492104f4)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #08 pc 000b1c13  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libc++_shared.so (__cxa_throw+115) (BuildId: e17c5af931f83c79fe858d7c19c030d4492104f4)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #09 pc 0001fef6  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libhermes.so (facebook::hermes::HermesRuntimeImpl::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned int)+1078) (BuildId: df8072863d396d57901d03a3514af58b13e5c804)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #10 pc 0001854b  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libhermes-executor-common-debug.so (BuildId: feaf1ba9dd56d4aee4cd4cd150b3e084685387b6)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #11 pc 0004577e  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libreactnativemmkv.so (facebook::jsi::Function::createFromHostFunction(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, unsigned int, std::__ndk1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned int)>)+190) (BuildId: a580b0a467b65516948d40dbb8be6a779ad13939)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #12 pc 00045548  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libreactnativemmkv.so (install(facebook::jsi::Runtime&)+200) (BuildId: a580b0a467b65516948d40dbb8be6a779ad13939)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #13 pc 000463e0  /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/lib/x86/libreactnativemmkv.so (Java_com_reactnativemmkv_MmkvModule_nativeInstall+208) (BuildId: a580b0a467b65516948d40dbb8be6a779ad13939)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #14 pc 00144f67  /apex/com.android.runtime/lib/libart.so (art_quick_generic_jni_trampoline+71) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #15 pc 0013e9a2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+418) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #16 pc 00149a7a  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #17 pc 00332502  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+386) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #18 pc 0032c19c  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+988) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.181 27264-27264/? A/DEBUG:       #19 pc 00684d03  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+643) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.182 27264-27264/? A/DEBUG:       #20 pc 001389a1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.183 27264-27264/? A/DEBUG:       #21 pc 000004fc  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/base.apk!classes3.dex] (com.reactnativemmkv.MmkvModule.install+8)
2021-09-03 14:59:52.183 27264-27264/? A/DEBUG:       #22 pc 002f8e0a  /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.12194892193087984976+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.183 27264-27264/? A/DEBUG:       #23 pc 002ffe19  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+217) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.183 27264-27264/? A/DEBUG:       #24 pc 0032c17e  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+958) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.183 27264-27264/? A/DEBUG:       #25 pc 00684d03  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+643) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #26 pc 001389a1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #27 pc 0000046e  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/base.apk!classes3.dex] (com.reactnativemmkv.MmkvModulePackage.getJSIModules+54)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #28 pc 006837bc  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1980) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #29 pc 00138a21  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #30 pc 001c9a70  [anon:dalvik-classes.dex extracted in memory from /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/base.apk] (com.facebook.react.ReactInstanceManager.createReactContext+212)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #31 pc 006845ac  /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+1324) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #32 pc 00138921  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #33 pc 001c9980  [anon:dalvik-classes.dex extracted in memory from /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/base.apk] (com.facebook.react.ReactInstanceManager.access$1100)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #34 pc 00684f6c  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+1260) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.184 27264-27264/? A/DEBUG:       #35 pc 001389a1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #36 pc 001c909c  [anon:dalvik-classes.dex extracted in memory from /data/app/com.example.reactnativemmkv-CHuAkiXYmYganO7ZXIfhRA==/base.apk] (com.facebook.react.ReactInstanceManager$5.run+140)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #37 pc 006837bc  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1980) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #38 pc 00138a21  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #39 pc 000ea918  /apex/com.android.runtime/javalib/core-oj.jar (java.lang.Thread.run+8)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #40 pc 002f8e0a  /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.12194892193087984976+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #41 pc 002ffcc5  /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+181) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #42 pc 0066fbd9  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+1209) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.185 27264-27264/? A/DEBUG:       #43 pc 0014503d  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+77) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #44 pc 0013e7d2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+338) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #45 pc 00149a69  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+281) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #46 pc 0055a513  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+99) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #47 pc 0055b91a  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+474) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #48 pc 005aaa51  /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+1585) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #49 pc 0011a8e5  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+53) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2021-09-03 14:59:52.186 27264-27264/? A/DEBUG:       #50 pc 000af6a7  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
@mrousavy mrousavy added the bug Something isn't working label Sep 3, 2021
@mrousavy
Copy link
Contributor Author

mrousavy commented Sep 3, 2021

Hmm, not even this code works:

jsiRuntime.global().setProperty(jsiRuntime, "teeeeeeeest", jsi::Value(42));

maybe the runtime pointer is corrupted?

@neildhar
Copy link
Contributor

neildhar commented Sep 4, 2021

Hi @mrousavy, is it possible that the copy of JSI being used does not line up with the version of Hermes being used? It seems suspicious that facebook::jsi::Function::createFromHostFunction is calling facebook::hermes::HermesRuntimeImpl::call. I noticed your build is using JSI from an RN checkout in another directory, is that checkout at the corresponding version?

@mrousavy
Copy link
Contributor Author

mrousavy commented Sep 6, 2021

Okay so I did a bit of investigation and it seems like this error is also happening with JSC. Looks like I was wrong ticking that box above, sorry!

I am still not sure why this keeps happening, do you maybe have an idea @neildhar?

A lot of people report this issue, with kind-of different crash logs
mrousavy/react-native-mmkv#88, mrousavy/react-native-mmkv#122, mrousavy/react-native-mmkv#111 or mrousavy/react-native-mmkv#98

I'm essentially just installing a single function in the jsi::Runtime before the JS bundle starts executing, and I achieve this by

  1. creating a JSIModulePackage, overriding the getJSIModules function and calling the native C++ function with the passed JavaScriptContextHolder.get() pointer. (see code here)
  2. Then, I reinterpret_cast the long JS Context pointer to a jsi::Runtime* (see code here)
  3. dereference that and pass it to my install function (see code here), which then
  4. creates a new jsi::Function from a Host Function and calls .global().setProperty(..) (see code here).

Apparently for some people accessing .global() crashes, while for others jsi::Function::createFromHostFunction crashes.

This seems so weird to me, maybe I got the jsi::Runtime wrong and it's an invalid pointer?

Maybe also important: my CMakeLists.txt and my build.gradle.

@mrousavy
Copy link
Contributor Author

mrousavy commented Sep 6, 2021

Apparently it works on RN 0.65.1, but crashes on RN 0.64.2....

@mrousavy
Copy link
Contributor Author

mrousavy commented Sep 6, 2021

Looks like we're talking about this error:

hermes/API/hermes/hermes.cpp

Lines 2003 to 2009 in 6e58687

if (count > std::numeric_limits<uint32_t>::max() ||
!runtime_.checkAvailableStack((uint32_t)count)) {
LOG_EXCEPTION_CAUSE(
"HermesRuntimeImpl::call: Unable to call function: stack overflow");
throw jsi::JSINativeException(
"HermesRuntimeImpl::call: Unable to call function: stack overflow");
}

why does count get range checked here, aren't those the function arguments?

@neildhar
Copy link
Contributor

neildhar commented Sep 6, 2021

I don't believe it should be calling HermesRuntimeImpl::call at all, did you check the version of JSI being used as mentioned in my previous comment? The fact that it works on 0.65.1 but not on 0.64 also lines up with the possibility that you're using JSI from a checkout of RN that is on the 0.65 branch or main.

JSI can change from one version of RN to another, so you need to build your plugin against JSI from the right version of RN.

@mrousavy
Copy link
Contributor Author

mrousavy commented Sep 6, 2021

Oh I'm sorry I misunderstood the previous comment about the JSI version!
That makes sense, I might have to distribute react-native-mmkv as source instead of prebuilding it on my machine (.aar). I thought this would not link it against RN/JSI but apparently it does.

I guess since this is unrelated to hermes we can close this now, thanks for your help.

@mrousavy mrousavy closed this as completed Sep 6, 2021
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

2 participants