Closed HeribertoAlves closed 4 years ago
I think the root cause is in facebook::jsi::valueFromDynamic
:
case folly::dynamic::OBJECT: {
Object ret(runtime);
for (const auto& element : dyn.items()) {
Value value = valueFromDynamic(runtime, element.second);
if (element.first.isNumber() || element.first.isString()) {
ret.setProperty(runtime, element.first.asString().c_str(), value); // HERE
}
}
return std::move(ret);
}
This code will call into setProperty
with a const char *
, which it assumes is ASCII.
What is most likely happening is that you have a non-ASCII character going over the bridge (MessageQueue
).
@HeribertoAlves, if you are willing to make a small change to the C++ files and re-compile your app,
can you try changing the line I show in valueFromDynamic
(in JSIDynamic.cpp) to be this instead?
ret.setProperty(runtime, PropNameID::forUtf8(runtime, element.first.asString()), value);
If that fixes the issue, you or I can open up a PR for that fix to JSI.
It worked. I think it is best(and fair) if you open a PR because you developed the solution! :)
Ok landed a commit to fix this in RN: https://github.com/facebook/react-native/commit/c24387e45c0d99dc059f2f7bbaa76be47f3f40c2. Closing this as resolved.
Stil seeing this in 0.60.5
@dulinriley I applied your above patch and then did a gradle clean and then ran the build again and i'm still facing this error. Have I missed a step?
@mtford90 this error could be coming from any place where you pass a non-ASCII (UTF-8 or UTFf-16) string into a Hermes/JSI API that expects ASCII characters.
Is the stack trace for the crash at the same spot? I landed the fix to valueFromDynamic
so it shouldn't be coming from there anymore.
Hi @dulinriley! The error happens this the same place. I have to manually re-apply what you have done. I can confirm that it was not deployed on 0.60.5.
@dulinriley looks the same to me:
2019-08-23 18:49:04.669 4302-4302/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-08-23 18:49:04.669 4302-4302/? A/DEBUG: Build fingerprint: 'Android/vbox86p/vbox86p:7.0/NRD90M/391:userdebug/test-keys'
2019-08-23 18:49:04.669 4302-4302/? A/DEBUG: Revision: '0'
2019-08-23 18:49:04.669 4302-4302/? A/DEBUG: ABI: 'x86'
2019-08-23 18:49:04.669 4302-4302/? A/DEBUG: pid: 4039, tid: 4197, name: mqt_js >>> com.genolingo.genolingo <<<
2019-08-23 18:49:04.670 4302-4302/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2019-08-23 18:49:04.672 4302-4302/? A/DEBUG: Abort message: '/Users/willholen/intern/hermes/API/hermes/hermes.cpp:1378: auto facebook::hermes::HermesRuntimeImpl::createStringFromAscii(const char *, size_t)::(anonymous class)::operator()() const: assertion "static_cast<unsigned char>(str[i]) < 128 && "non-ASCII character in string"" failed'
2019-08-23 18:49:04.673 4302-4302/? A/DEBUG: eax 00000000 ebx 00000fc7 ecx 00001065 edx 00000006
2019-08-23 18:49:04.673 4302-4302/? A/DEBUG: esi c2af9978 edi c2af9920
2019-08-23 18:49:04.673 4302-4302/? A/DEBUG: xcs 00000023 xds 0000002b xes 0000002b xfs 0000006b xss 0000002b
2019-08-23 18:49:04.673 4302-4302/? A/DEBUG: eip eea55bb9 ebp c2af84a8 esp c2af844c flags 00000292
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: backtrace:
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #00 pc 00000bb9 [vdso:eea55000] (__kernel_vsyscall+9)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #01 pc 0007a2ec /system/lib/libc.so (tgkill+28)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #02 pc 00075b35 /system/lib/libc.so (pthread_kill+85)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #03 pc 0002784a /system/lib/libc.so (raise+42)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #04 pc 0001ee26 /system/lib/libc.so (abort+86)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #05 pc 00023d38 /system/lib/libc.so (__libc_fatal+40)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #06 pc 0001f2f0 /system/lib/libc.so (__assert2+64)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #07 pc 000174eb /data/app/com.genolingo.genolingo-1/lib/x86/libhermes.so (_ZN8facebook6hermes17HermesRuntimeImpl21createStringFromAsciiEPKcj+427)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #08 pc 0001a54a /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #09 pc 0003500d /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi6Object11setPropertyIRNS0_5ValueEEEvRNS0_7RuntimeEPKcOT_+77)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #10 pc 00034d54 /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi16valueFromDynamicERNS0_7RuntimeERKN5folly7dynamicE+580)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #11 pc 00034cff /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi16valueFromDynamicERNS0_7RuntimeERKN5folly7dynamicE+495)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #12 pc 00034cff /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi16valueFromDynamicERNS0_7RuntimeERKN5folly7dynamicE+495)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #13 pc 00034cff /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi16valueFromDynamicERNS0_7RuntimeERKN5folly7dynamicE+495)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #14 pc 00034c66 /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook3jsi16valueFromDynamicERNS0_7RuntimeERKN5folly7dynamicE+342)
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #15 pc 00027c72 /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so
2019-08-23 18:49:04.679 4302-4302/? A/DEBUG: #16 pc 0001f237 /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt6__ndk18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE+39)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #17 pc 000227b7 /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZNSt6__ndk128__invoke_void_return_wrapperIvE6__callIJRPFvRKNS_8functionIFvvEEENS3_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEES7_SF_EEEvDpOT_+119)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #18 pc 000226da /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZNSt6__ndk110__function6__funcIPFvRKNS_8functionIFvvEEENS2_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEENSA_ISG_EESF_EclES6_OSE_+42)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #19 pc 0002533a /data/app/com.genolingo.genolingo-1/lib/x86/libhermes-executor-debug.so (_ZN8facebook5react11JSIExecutor12callFunctionERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_RKN5folly7dynamicE+1482)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #20 pc 000a4bbe /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #21 pc 000a63fe /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #22 pc 00061727 /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #23 pc 0004ed72 /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so (_ZN8facebook3jni6detail13MethodWrapperIMNS_5react15JNativeRunnableEFvvEXadL_ZNS4_3runEvEES4_vJEE8dispatchENS0_9alias_refIPNS1_8JTypeForINS0_11HybridClassIS4_NS3_8RunnableEE8JavaPartESB_vE11_javaobjectEEE+50)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #24 pc 0004ecd9 /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so (_ZN8facebook3jni6detail15FunctionWrapperIPFvNS0_9alias_refIPNS1_8JTypeForINS0_11HybridClassINS_5react15JNativeRunnableENS6_8RunnableEE8JavaPartES8_vE11_javaobjectEEEEXadL_ZNS1_13MethodWrapperIMS7_FvvEXadL_ZNS7_3runEvEES7_vJEE8dispatchESE_EESD_vJEE4callEP7_JNIEnvP8_jobject+73)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #25 pc 0004ec83 /data/app/com.genolingo.genolingo-1/lib/x86/libreactnativejni.so (_ZN8facebook3jni6detail13MethodWrapperIMNS_5react15JNativeRunnableEFvvEXadL_ZNS4_3runEvEES4_vJEE4callEP7_JNIEnvP8_jobject+35)
2019-08-23 18:49:04.680 4302-4302/? A/DEBUG: #26 pc 01407d8c /data/app/com.genolingo.genolingo-1/oat/x86/base.odex (offset 0x13ab000)
@HeribertoAlves looks like my commit is tagged with the 0.61 release candidate of React Native. I'm not sure if that's available for download (as a binary package) or not, so you'll probably need to build from master.
@HeribertoAlves looks like my commit is tagged with the 0.61 release candidate of React Native. I'm not sure if that's available for download (as a binary package) or not, so you'll probably need to build from master.
Thanks for your reply @dulinriley ! Not a problem for me. I created a script that handles this issue. I'll just have to wait for 0.61 version.
I open this new issue as @dulinriley requested. It crash with the error below:
A/libc: /Users/willholen/intern/hermes/API/hermes/hermes.cpp:1378: auto facebook::hermes::HermesRuntimeImpl::createStringFromAscii(const char *, size_t)::(anonymous class)::operator()() const: assertion "static_cast(str[i]) < 128 && "non-ASCII character in string"" failed Fatal signal 6 (SIGABRT), code -6 in tid 22378 (mqt_js)
stack trace:
tgkill 0x0000007fb2680838 abort 0x0000007fb2632ed4 libc_fatal 0x0000007fb263aee0 _assert2 0x0000007fb2633624 facebook::hermes::HermesRuntimeImpl::createStringFromAscii(char const, unsigned long) 0x0000007f8e129914 void facebook::jsi::Object::setPropertyfacebook::jsi::Value&(facebook::jsi::Runtime&, char const, facebook::jsi::Value&&&) 0x0000007f9030b458 facebook::jsi::valueFromDynamic(facebook::jsi::Runtime&, folly::dynamic const&) 0x0000007f9030b198 facebook::jsi::valueFromDynamic(facebook::jsi::Runtime&, folly::dynamic const&) 0x0000007f9030b154 facebook::jsi::valueFromDynamic(facebook::jsi::Runtime&, folly::dynamic const&) 0x0000007f9030b154 facebook::jsi::valueFromDynamic(facebook::jsi::Runtime&, folly::dynamic const&) 0x0000007f9030b0cc facebook::react::JSIExecutor::invokeCallback(double, folly::dynamic const&) 0x0000007f902fe01c lldb_unnamed_symbol185$$libreactnativejni.so 0x0000007f90ba7dc4 _lldb_unnamedsymbol228$$libreactnativejni.so 0x0000007f90ba8de4 lldb_unnamed_symbol42$$libreactnativejni.so 0x0000007f90b6b8c0 facebook::jni::detail::MethodWrapper<void (facebook::react::JNativeRunnable::)(), &(facebook::react::JNativeRunnable::run()), facebook::react::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject>) 0x0000007f90b5ac78 facebook::jni::detail::FunctionWrapper<void ()(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject>), &(facebook::jni::detail::MethodWrapper<void (facebook::react::JNativeRunnable::)(), &(facebook::react::JNativeRunnable::run()), facebook::react::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject>)), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject, void>::call(_JNIEnv, _jobject) 0x0000007f90b5abf4 art_quick_generic_jni_trampoline 0x0000007fae2bc504 0x00000000996d5bd8 art::ArtMethod::Invoke(art::Thread, unsigned int, unsigned int, art::JValue, char const) 0x0000007fade82da4 art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread, art::ArtMethod, art::DexFile::CodeItem const, art::ShadowFrame, art::JValue) 0x0000007fae02d488 bool art::interpreter::DoCall<false, false>(art::ArtMethod, art::Thread, art::ShadowFrame&, art::Instruction const, unsigned short, art::JValue) 0x0000007fae027b50 bool art::interpreter::DoInvoke<(art::InvokeType)0, false, false>(art::Thread, art::ShadowFrame&, art::Instruction const, unsigned short, art::JValue) 0x0000007fae054a64 art::JValue art::interpreter::ExecuteSwitchImpl<false, false>(art::Thread, art::DexFile::CodeItem const, art::ShadowFrame&, art::JValue, bool) 0x0000007fae04c040 art::interpreter::Execute(art::Thread, art::DexFile::CodeItem const, art::ShadowFrame&, art::JValue, bool) 0x0000007fae008930 art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread, art::DexFile::CodeItem const, art::ShadowFrame, art::JValue) 0x0000007fae00efcc bool art::interpreter::DoCall<false, false>(art::ArtMethod, art::Thread, art::ShadowFrame&, art::Instruction const, unsigned short, art::JValue) 0x0000007fae027b30 bool art::interpreter::DoInvoke<(art::InvokeType)3, false, false>(art::Thread, art::ShadowFrame&, art::Instruction const, unsigned short, art::JValue) 0x0000007fae05280c art::JValue art::interpreter::ExecuteSwitchImpl<false, false>(art::Thread, art::DexFile::CodeItem const, art::ShadowFrame&, art::JValue, bool) 0x0000007fae04fbec art::interpreter::Execute(art::Thread, art::DexFile::CodeItem const, art::ShadowFrame&, art::JValue, bool) 0x0000007fae008930 artQuickToInterpreterBridge 0x0000007fae28e958 art_quick_to_interpreter_bridge 0x0000007fae2bc620 0x00000000996983e0