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

Crash when calling Intl.NumberFormat during module init #513

Closed
1 task done
janicduplessis opened this issue May 21, 2021 · 2 comments
Closed
1 task done

Crash when calling Intl.NumberFormat during module init #513

janicduplessis opened this issue May 21, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@janicduplessis
Copy link

Bug Description

Calling Intl.NumberFormat during module initialization causes the following crash. I noticed this issue when including the formatjs numberformat polyfill (https://github.com/formatjs/formatjs/blob/main/packages/intl-numberformat/should-polyfill.ts#L21).

********** Crash dump: **********
Build fingerprint: 'google/volantis/flounder:7.1.1/N9F27M/4333998:user/release-keys'
Abort message: 'terminating with uncaught exception of type std::runtime_error: Unable to retrieve jni environment. Is the thread attached?'
#00 0x000000000006b330 /system/lib64/libc.so (tgkill+8)
#01 0x00000000000687cc /system/lib64/libc.so (pthread_kill+64)
#02 0x0000000000023d2c /system/lib64/libc.so (raise+24)
#03 0x000000000001c7b0 /system/lib64/libc.so (abort+52)
#04 0x00000000000a01bc /data/app/com.th3rdwave-1/lib/arm64/libc++_shared.so
#05 0x00000000000a03b0 /data/app/com.th3rdwave-1/lib/arm64/libc++_shared.so
#06 0x00000000000b4208 /data/app/com.th3rdwave-1/lib/arm64/libc++_shared.so
#07 0x00000000000b41a0 /data/app/com.th3rdwave-1/lib/arm64/libc++_shared.so (_ZSt9terminatev+36)
#08 0x000000000003828c /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
__clang_call_terminate
??:0:0
#09 0x000000000014991c /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
facebook::jni::GlobalReferenceAllocator::deleteReference(_jobject*) const
/home/circleci/project/first-party/fbjni/cxx/fbjni/detail/ReferenceAllocators-inl.h:87:3
facebook::jni::base_owned_ref<hermes::platform_intl::(anonymous namespace)::JNumberFormat, facebook::jni::GlobalReferenceAllocator>::reset(facebook::jni::detail::JTypeFor<hermes::platform_intl::(anonymous namespace)::JNumberFormat, facebook::jni::JObject, void>::_javaobject*)
/home/circleci/project/first-party/fbjni/cxx/fbjni/detail/References-inl.h:289:0
facebook::jni::base_owned_ref<hermes::platform_intl::(anonymous namespace)::JNumberFormat, facebook::jni::GlobalReferenceAllocator>::reset()
/home/circleci/project/first-party/fbjni/cxx/fbjni/detail/References-inl.h:282:0
facebook::jni::base_owned_ref<hermes::platform_intl::(anonymous namespace)::JNumberFormat, facebook::jni::GlobalReferenceAllocator>::~base_owned_ref()
/home/circleci/project/first-party/fbjni/cxx/fbjni/detail/References-inl.h:268:0
hermes::platform_intl::NumberFormat::Impl::~Impl()
/home/circleci/project/lib/Platform/Intl/PlatformIntlAndroid.cpp:505:0
std::__ndk1::default_delete<hermes::platform_intl::NumberFormat::Impl>::operator()(hermes::platform_intl::NumberFormat::Impl*) const
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2339:0
std::__ndk1::unique_ptr<hermes::platform_intl::NumberFormat::Impl, std::__ndk1::default_delete<hermes::platform_intl::NumberFormat::Impl> >::reset(hermes::platform_intl::NumberFormat::Impl*)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2652:0
std::__ndk1::unique_ptr<hermes::platform_intl::NumberFormat::Impl, std::__ndk1::default_delete<hermes::platform_intl::NumberFormat::Impl> >::~unique_ptr()
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2606:0
hermes::platform_intl::NumberFormat::~NumberFormat()
/home/circleci/project/lib/Platform/Intl/PlatformIntlAndroid.cpp:511:0
hermes::platform_intl::NumberFormat::~NumberFormat()
/home/circleci/project/lib/Platform/Intl/PlatformIntlAndroid.cpp:511:0
#10 0x000000000011efcc /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
hermes::vm::VTable::finalizeIfExists(hermes::vm::GCCell*, hermes::vm::HadesGC*) const
/home/circleci/project/include/hermes/VM/VTable.h:167:7
hermes::vm::HadesGC::OldGen::sweepNext(bool)
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1165:0
#11 0x000000000012214c /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
hermes::vm::HadesGC::incrementalCollect(bool)
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1672:20
#12 0x000000000012a144 /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
hermes::vm::HadesGC::collectOGInBackground()::$_1::operator()() const
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1633:7
decltype(std::__ndk1::forward<hermes::vm::HadesGC::collectOGInBackground()::$_1&>(fp)()) std::__ndk1::__invoke<hermes::vm::HadesGC::collectOGInBackground()::$_1&>(hermes::vm::HadesGC::collectOGInBackground()::$_1&)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:4353:0
void std::__ndk1::__invoke_void_return_wrapper<void>::__call<hermes::vm::HadesGC::collectOGInBackground()::$_1&>(hermes::vm::HadesGC::collectOGInBackground()::$_1&)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__functional_base:349:0
std::__ndk1::__function::__alloc_func<hermes::vm::HadesGC::collectOGInBackground()::$_1, std::__ndk1::allocator<hermes::vm::HadesGC::collectOGInBackground()::$_1>, void ()>::operator()()
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1527:0
std::__ndk1::__function::__func<hermes::vm::HadesGC::collectOGInBackground()::$_1, std::__ndk1::allocator<hermes::vm::HadesGC::collectOGInBackground()::$_1>, void ()>::operator()()
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1651:0
#13 0x0000000000128974 /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
std::__ndk1::__function::__value_func<void ()>::operator()() const
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1799:16
std::__ndk1::function<void ()>::operator()() const
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:2347:0
hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()::operator()() const
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1045:0
decltype(std::__ndk1::forward<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()&>(fp)()) std::__ndk1::__invoke<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()&>(hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()&)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:4353:0
void std::__ndk1::__invoke_void_return_wrapper<void>::__call<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()&>(hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()&)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__functional_base:349:0
std::__ndk1::__function::__alloc_func<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'(), std::__ndk1::allocator<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()>, void ()>::operator()()
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1527:0
std::__ndk1::__function::__func<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'(), std::__ndk1::allocator<hermes::vm::HadesGC::Executor::add(std::__ndk1::function<void ()>)::'lambda'()>, void ()>::operator()()
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1651:0
#14 0x000000000012998c /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
std::__ndk1::__function::__value_func<void ()>::operator()() const
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:1799:16
std::__ndk1::function<void ()>::operator()() const
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/functional:2347:0
hermes::vm::HadesGC::Executor::worker()
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1066:0
#15 0x0000000000129790 /data/app/com.th3rdwave-1/lib/arm64/libhermes.so
hermes::vm::HadesGC::Executor::Executor()::'lambda'()::operator()() const
/home/circleci/project/lib/VM/gcs/HadesGC.cpp:1028:33
decltype(std::__ndk1::forward<hermes::vm::HadesGC::Executor::Executor()::'lambda'()>(fp)()) std::__ndk1::__invoke<hermes::vm::HadesGC::Executor::Executor()::'lambda'()>(hermes::vm::HadesGC::Executor::Executor()::'lambda'()&&)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:4353:0
void std::__ndk1::__thread_execute<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct> >, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>(std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct> >, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>&, std::__ndk1::__tuple_indices<>)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/thread:342:0
void* std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct> >, hermes::vm::HadesGC::Executor::Executor()::'lambda'()> >(void*)
/opt/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/thread:352:0
#16 0x0000000000067fd4 /system/lib64/libc.so (_ZL15__pthread_startPv+196)
#17 0x000000000001d9c4 /system/lib64/libc.so (__start_thread+16)
  • I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.8.0
React Native version (if any): master@b2dbde36b8f9cb69b1a1f9061c7f19c895d0c317
OS version (if any): Android 7.1.1
Platform: arm64-v8a

Steps To Reproduce

I was only able to reproduce the crash on a physical device, not on the emulator. The crash happens both in debug and release builds.

React Native index.js

const s = new Intl.NumberFormat('en', {
    style: 'unit',
    unit: 'bit',
    unitDisplay: 'long',
    notation: 'scientific',
  }).format(10000);

  console.log(s);
  
  AppRegistry.registerComponent(...)

Running the same code inside setTimeout(..., 0) does not crash.

The Expected Behavior

No crash

@janicduplessis janicduplessis added the bug Something isn't working label May 21, 2021
@neildhar
Copy link
Contributor

Thanks for reporting this! This is a bug in how the Intl implementation is interacting with the new concurrent garbage collector. We'll work on a fix.

@neildhar
Copy link
Contributor

neildhar commented Jun 8, 2021

Should be fixed in 1b3a0c2, please feel free to reopen this issue if you're still seeing the bug in the next release.

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