Fantom's tester reports a mount inside the commit, so under preventShadowTreeCommitExhaustion it takes the shadow tree registry's lock while holding the revision lock

Open
#59,673 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, react-native
Domain
mobile, testing

Research direction

Start with packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp, especially the locked last attempt in commit/tryCommit, and ShadowTreeRegistry.cpp's visit/enumerate. Trace TesterMountingManager::executeMount into Scheduler::reportMount and UIManager::reportMount to confirm where the registry lock is taken while the revision lock is held, then run the reproducer with fantom/reproduce.sh tsan-mount-inside-locked-commit. Done means the tester's mount reporting no longer creates a lock-order inversion under ThreadSanitizer, with the test staying green.

Written by the indexing model from the issue text.

Description

Description

Fantom's tester reports each mount from inside the commit that mounts it: TesterMountingManager::executeMount calls back into Scheduler::reportMount, and UIManager::reportMount takes ShadowTreeRegistry's lock through visit. With preventShadowTreeCommitExhaustion on, ShadowTree::commit makes its last attempt holding revisionMutexRecursive_ for the whole tryCommit, mount() included, so a commit that mounts synchronously and reaches that attempt takes the registry's lock while it holds the revision lock. Code that reaches a tree through the registry takes the two the other way round, the registry's first: the tester's own startSurface reads the current revision inside visit, and UIManager commits inside visit or enumerate (setNativeProps_DEPRECATED, updateShadowTree). ThreadSanitizer reports the cycle as a potential deadlock.

Android and iOS report a mount later, on the main thread, once its effects are visible (FabricUIManager.didMountItems, RCTSurfacePresenter's mountingManager:didMountComponentsWithRootTag:), outside the commit, so only the tester reports mounts under the revision lock.

To reach the locked attempt every time, the reproducer adds a commit hook to the tester that lands a commit of the same tree from another thread inside each of a synchronous commit's first three attempts, as a per-frame committer can. The commit that then mounts under the lock is a stock one: the empty-tree commit SurfaceHandler::stop makes when a test destroys its root.

Steps to reproduce
  1. git clone https://github.com/YevheniiKotyrlo/react-native-fantom-reproducer && cd react-native-fantom-reproducer
  2. ./fantom/reproduce.sh tsan-mount-inside-locked-commit (needs Docker). It clones react/react-native at main, applies fantom/contending-commit-hook.patch to the tester, builds Hermes and the tester under ThreadSanitizer, and runs fantom/LockedCommitMount-itest.js, shown here without its license header and imports:
/**
 * @fantom_flags preventShadowTreeCommitExhaustion:true
 */

describe('a surface stopped under contention', () => {
  it('commits its empty tree in the locked attempt', () => {
    const root = Fantom.createRoot();

    Fantom.runTask(() => {
      root.render(<View nativeID="view" />);
    });

    root.destroy();
  });
});

The same on a checkout of main: git apply the patch, put the test at packages/react-native/Libraries/Components/View/__tests__/LockedCommitMount-itest.js, then

export CFLAGS=-fsanitize=thread
export CXXFLAGS="-fsanitize=thread -Wno-error=deprecated-literal-operator"
export LDFLAGS="-fuse-ld=lld -fsanitize=thread"
yarn workspace @react-native/fantom build
yarn fantom packages/react-native/Libraries/Components/View/__tests__/LockedCommitMount-itest.js

ThreadSanitizer re-executes the tester with address randomization off, which Docker's default seccomp profile refuses, so the reproducer's container runs with --security-opt seccomp=unconfined.

Expected: the test passes with no ThreadSanitizer report: the tester reports the mount outside the commit, as Android and iOS do, so no thread takes ShadowTreeRegistry's lock while it holds the revision lock.

Seen: ThreadSanitizer reports lock-order-inversion (potential deadlock) between the revision lock and ShadowTreeRegistry's lock (the log under Stacktrace or Logs).

React Native Version

0.88.0 (reproduced on main at 3aee67b)

Affected Platforms

Build - Linux

Output of npx @react-native-community/cli info
System:
  OS: Linux 6.18 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
  CPU: (24) x64 AMD Ryzen 9 9950X3D 16-Core Processor
  Memory: 116.43 GB / 125.63 GB
  Shell:
    version: 5.1.16
    path: /bin/bash
Binaries:
  Node:
    version: 22.14.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/local/bin/yarn
  npm:
    version: 10.9.2
    path: /usr/local/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "37"
    Build Tools:
      - 37.0.0
    Android NDK: 28.2.13676358
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: /usr/bin/javac
  Ruby:
    version: 3.0.2
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=7961)
  Cycle in lock order graph: M0 (0x724c00000770) => M1 (0x725800003948) => M0

  Mutex M1 acquired here while holding mutex M0 in main thread:
    #0 pthread_mutex_lock /home/runner/work/llvm-project/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1429:3 (fantom_tester+0x5b2727)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749:21 (fantom_tester+0xbe0a5f)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:811:10 (fantom_tester+0xbe0a15)
    #3 std::recursive_mutex::lock() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/mutex:108:17 (fantom_tester+0xbea8e5)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_lock.h:139:17 (fantom_tester+0xbea887)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_lock.h:69:2 (fantom_tester+0xbe332e)
    #6 facebook::react::ShadowTree::sharedRevisionLock() const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:655:12 (fantom_tester+0xbe31d8)
    #7 facebook::react::ShadowTree::getCurrentRevision() const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:479:21 (fantom_tester+0xbdefad)
    #8 facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0::operator()(facebook::react::ShadowTree const&) const /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:310:36 (fantom_tester+0x674728)
    #9 void std::__invoke_impl<void, facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0&, facebook::react::ShadowTree const&>(std::__invoke_other, facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0&, facebook::react::ShadowTree const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x674695)
    #10 std::enable_if<is_invocable_r_v<void, facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0&, facebook::react::ShadowTree const&>, void>::type std::__invoke_r<void, facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0&, facebook::react::ShadowTree const&>(facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0&, facebook::react::ShadowTree const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:111:2 (fantom_tester+0x6745e5)
    #11 std::_Function_handler<void (facebook::react::ShadowTree const&), facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float)::$_0>::_M_invoke(std::_Any_data const&, facebook::react::ShadowTree const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x674454)
    #12 std::function<void (facebook::react::ShadowTree const&)>::operator()(facebook::react::ShadowTree const&) const /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:590:9 (fantom_tester+0xbfb89d)
    #13 facebook::react::ShadowTreeRegistry::visit(int, std::function<void (facebook::react::ShadowTree const&)> const&) const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp:50:3 (fantom_tester+0xbfb023)
    #14 facebook::react::TesterAppDelegate::startSurface(facebook::jsi::Runtime&, float, float, int, float, float, float, float) /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:307:60 (fantom_tester+0x66e38c)
    #15 facebook::react::NativeFantom::startSurface(facebook::jsi::Runtime&, double, double, double, double, double, double) /react-native/private/react-native-fantom/tester/src/NativeFantom.cpp:44:16 (fantom_tester+0x644d8d)
    #16 double facebook::react::bridging::callFromJs<double, facebook::react::NativeFantom, int, double, double, double, double, double, double, double, double, double, double, std::optional<double>, std::optional<double>>(facebook::jsi::Runtime&, int (facebook::react::NativeFantom::*)(facebook::jsi::Runtime&, double, double, double, double, double, double), std::shared_ptr<facebook::react::CallInvoker> const&, facebook::react::NativeFantom*, double&&, double&&, double&&, double&&, std::optional<double>&&, std::optional<double>&&) /react-native/packages/react-native/ReactCommon/react/bridging/Class.h:42:21 (fantom_tester+0x65379f)
    #17 facebook::react::NativeFantomCxxSpec<facebook::react::NativeFantom>::__startSurface(facebook::jsi::Runtime&, facebook::react::TurboModule&, facebook::jsi::Value const*, unsigned long) /react-native/private/react-native-fantom/build/codegen/react/renderer/components/FBReactNativeSpec/FBReactNativeSpecJSI.h:5629:12 (fantom_tester+0x64ff52)
    #18 facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const /react-native/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h:130:20 (fantom_tester+0x66982e)
    #19 facebook::jsi::Value std::__invoke_impl<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(std::__invoke_other, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x669751)
    #20 std::enable_if<is_invocable_r_v<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>, facebook::jsi::Value>::type std::__invoke_r<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:114:9 (fantom_tester+0x669608)
    #21 std::_Function_handler<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::_M_invoke(std::_Any_data const&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x6693ab)
    #22 facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::HFContext::func(void*, hermes::vm::Runtime&) hermes.cpp (libhermesvm.so+0x182deb)
    #23 hermes::vm::Interpreter::handleCallSlowPath(hermes::vm::Runtime&, hermes::vm::PinnedHermesValue*) Interpreter.cpp (libhermesvm.so+0x4ac899)
    #24 hermes::vm::CallResult<hermes::vm::HermesValue, (hermes::vm::detail::CallResultSpecialize)2> hermes::vm::Interpreter::interpretFunction<false, false>(hermes::vm::Runtime&, hermes::vm::InterpreterState&) Interpreter.cpp (libhermesvm.so+0x4adc4b)
    #25 hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock*) Interpreter.cpp (libhermesvm.so+0x4aca58)
    #26 hermes::vm::Runtime::interpretFunction(hermes::vm::CodeBlock*) Interpreter.cpp (libhermesvm.so+0x4bb6be)
    #27 hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&) Callable.cpp (libhermesvm.so+0x47ee20)
    #28 facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) hermes.cpp (libhermesvm.so+0x16d73c)
    #29 facebook::jsi::Function::call(facebook::jsi::IRuntime&, facebook::jsi::Value const*, unsigned long) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:325:18 (fantom_tester+0x696b52)
    #30 facebook::jsi::Function::call(facebook::jsi::IRuntime&, std::initializer_list<facebook::jsi::Value>) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:331:10 (fantom_tester+0x696a07)
    #31 facebook::jsi::Value facebook::jsi::Function::call<>(facebook::jsi::IRuntime&) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:339:10 (fantom_tester+0x676498)
    #32 facebook::react::TesterAppDelegate::loadScriptAndRunTests(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:200:8 (fantom_tester+0x66ccf3)
    #33 main /react-native/private/react-native-fantom/tester/src/main.cpp:79:15 (fantom_tester+0x71580e)
    #34 main /react-native/private/react-native-fantom/tester/src/main.cpp:58:22 (fantom_tester+0x715621)

    HINT: use TSAN_OPTIONS=second_deadlock_stack=1 to get more informative warning message

  Mutex M0 acquired here while holding mutex M1 in main thread:
    #0 pthread_rwlock_rdlock /home/runner/work/llvm-project/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1590:3 (fantom_tester+0x5b3bb7)
    #1 std::__glibcxx_rwlock_rdlock(pthread_rwlock_t*) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/shared_mutex:78:3 (fantom_tester+0x69ed4f)
    #2 std::__shared_mutex_pthread::lock_shared() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/shared_mutex:229:10 (fantom_tester+0x6b438d)
    #3 std::shared_mutex::lock_shared() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/shared_mutex:426:34 (fantom_tester+0x6b4335)
    #4 std::shared_lock<std::shared_mutex>::shared_lock(std::shared_mutex&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/shared_mutex:727:13 (fantom_tester+0x6b4012)
    #5 facebook::react::ShadowTreeRegistry::visit(int, std::function<void (facebook::react::ShadowTree const&)> const&) const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp:42:20 (fantom_tester+0xbfaf5e)
    #6 facebook::react::UIManager::reportMount(int) const /react-native/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp:697:23 (fantom_tester+0xc9b20e)
    #7 facebook::react::Scheduler::reportMount(int) const /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp:459:15 (fantom_tester+0x11ec29d)
    #8 facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)::operator()(facebook::react::Scheduler&) const /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:84:21 (fantom_tester+0x67047c)
    #9 void std::__invoke_impl<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)&, facebook::react::Scheduler&>(std::__invoke_other, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)&, facebook::react::Scheduler&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x6703f5)
    #10 std::enable_if<is_invocable_r_v<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)&, facebook::react::Scheduler&>, void>::type std::__invoke_r<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)&, facebook::react::Scheduler&>(facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)&, facebook::react::Scheduler&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:111:2 (fantom_tester+0x670345)
    #11 std::_Function_handler<void (facebook::react::Scheduler&), facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const::'lambda'(facebook::react::Scheduler&)>::_M_invoke(std::_Any_data const&, facebook::react::Scheduler&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x6701b4)
    #12 std::function<void (facebook::react::Scheduler&)>::operator()(facebook::react::Scheduler&) const /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:590:9 (fantom_tester+0x10b598d)
    #13 facebook::react::ReactHost::runOnScheduler(std::function<void (facebook::react::Scheduler&)>&&) const /react-native/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp:458:5 (fantom_tester+0x10ab084)
    #14 facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0::operator()(int) const /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:83:21 (fantom_tester+0x66fff5)
    #15 void std::__invoke_impl<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0&, int>(std::__invoke_other, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0&, int&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x66ff4c)
    #16 std::enable_if<is_invocable_r_v<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0&, int>, void>::type std::__invoke_r<void, facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0&, int>(facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0&, int&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:111:2 (fantom_tester+0x66fe85)
    #17 std::_Function_handler<void (int), facebook::react::TesterAppDelegate::TesterAppDelegate(facebook::react::ReactInstanceConfig const&)::$_0>::_M_invoke(std::_Any_data const&, int&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x66fcf4)
    #18 std::function<void (int)>::operator()(int) const /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:590:9 (fantom_tester+0x69f513)
    #19 facebook::react::TesterMountingManager::executeMount(int, facebook::react::MountingTransaction&&) /react-native/private/react-native-fantom/tester/src/TesterMountingManager.cpp:41:5 (fantom_tester+0x69e136)
    #20 facebook::react::SchedulerDelegateImpl::schedulerShouldRenderTransactions(std::shared_ptr<facebook::react::MountingCoordinator const> const&) /react-native/packages/react-native/ReactCxxPlatform/react/renderer/scheduler/SchedulerDelegateImpl.cpp:34:25 (fantom_tester+0x1087770)
    #21 facebook::react::Scheduler::uiManagerDidFinishTransaction(std::shared_ptr<facebook::react::MountingCoordinator const>, bool) /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp:319:18 (fantom_tester+0x11eadea)
    #22 facebook::react::UIManager::shadowTreeDidFinishTransaction(std::shared_ptr<facebook::react::MountingCoordinator const>, bool) const /react-native/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp:664:16 (fantom_tester+0xc9aebc)
    #23 facebook::react::ShadowTree::mount(facebook::react::ShadowTreeRevision, bool) const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:491:13 (fantom_tester+0xbdd229)
    #24 facebook::react::ShadowTree::tryCommit(std::function<std::shared_ptr<facebook::react::RootShadowNode> (facebook::react::RootShadowNode const&)> const&, facebook::react::ShadowTreeCommitOptions const&) const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:472:5 (fantom_tester+0xbde21f)
    #25 facebook::react::ShadowTree::commit(std::function<std::shared_ptr<facebook::react::RootShadowNode> (facebook::react::RootShadowNode const&)> const&, facebook::react::ShadowTreeCommitOptions const&) const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:319:14 (fantom_tester+0xbdd436)
    #26 facebook::react::ShadowTree::commitEmptyTree() const /react-native/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp:625:3 (fantom_tester+0xbdfe24)
    #27 facebook::react::SurfaceHandler::stop() const /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp:96:17 (fantom_tester+0x120ace7)
    #28 facebook::react::SurfaceManager::stopSurface(int)::$_0::operator()(facebook::react::SurfaceHandler const&) const /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp:49:20 (fantom_tester+0x120fd79)
    #29 void std::__invoke_impl<void, facebook::react::SurfaceManager::stopSurface(int)::$_0&, facebook::react::SurfaceHandler const&>(std::__invoke_other, facebook::react::SurfaceManager::stopSurface(int)::$_0&, facebook::react::SurfaceHandler const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x120fd15)
    #30 std::enable_if<is_invocable_r_v<void, facebook::react::SurfaceManager::stopSurface(int)::$_0&, facebook::react::SurfaceHandler const&>, void>::type std::__invoke_r<void, facebook::react::SurfaceManager::stopSurface(int)::$_0&, facebook::react::SurfaceHandler const&>(facebook::react::SurfaceManager::stopSurface(int)::$_0&, facebook::react::SurfaceHandler const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:111:2 (fantom_tester+0x120fc65)
    #31 std::_Function_handler<void (facebook::react::SurfaceHandler const&), facebook::react::SurfaceManager::stopSurface(int)::$_0>::_M_invoke(std::_Any_data const&, facebook::react::SurfaceHandler const&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x120fad4)
    #32 std::function<void (facebook::react::SurfaceHandler const&)>::operator()(facebook::react::SurfaceHandler const&) const /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:590:9 (fantom_tester+0x121229d)
    #33 facebook::react::SurfaceManager::visit(int, std::function<void (facebook::react::SurfaceHandler const&)> const&) const /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp:152:3 (fantom_tester+0x120e4eb)
    #34 facebook::react::SurfaceManager::stopSurface(int) /react-native/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp:48:3 (fantom_tester+0x120e6cd)
    #35 facebook::react::ReactHost::stopSurface(int) /react-native/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp:440:20 (fantom_tester+0x10aaf10)
    #36 facebook::react::TesterAppDelegate::stopSurface(int) /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:338:15 (fantom_tester+0x66e754)
    #37 facebook::react::NativeFantom::stopSurface(facebook::jsi::Runtime&, int) /react-native/private/react-native-fantom/tester/src/NativeFantom.cpp:57:16 (fantom_tester+0x644e28)
    #38 void facebook::react::bridging::callFromJs<void, facebook::react::NativeFantom, void, int, double>(facebook::jsi::Runtime&, void (facebook::react::NativeFantom::*)(facebook::jsi::Runtime&, int), std::shared_ptr<facebook::react::CallInvoker> const&, facebook::react::NativeFantom*, double&&) /react-native/packages/react-native/ReactCommon/react/bridging/Class.h:31:5 (fantom_tester+0x656aa4)
    #39 facebook::react::NativeFantomCxxSpec<facebook::react::NativeFantom>::__stopSurface(facebook::jsi::Runtime&, facebook::react::TurboModule&, facebook::jsi::Value const*, unsigned long) /react-native/private/react-native-fantom/build/codegen/react/renderer/components/FBReactNativeSpec/FBReactNativeSpecJSI.h:5642:5 (fantom_tester+0x6501fa)
    #40 facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const /react-native/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h:130:20 (fantom_tester+0x66982e)
    #41 facebook::jsi::Value std::__invoke_impl<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(std::__invoke_other, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14 (fantom_tester+0x669751)
    #42 std::enable_if<is_invocable_r_v<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>, facebook::jsi::Value>::type std::__invoke_r<facebook::jsi::Value, facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:114:9 (fantom_tester+0x669608)
    #43 std::_Function_handler<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), facebook::react::TurboModule::create(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::_M_invoke(std::_Any_data const&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:290:9 (fantom_tester+0x6693ab)
    #44 facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::HFContext::func(void*, hermes::vm::Runtime&) hermes.cpp (libhermesvm.so+0x182deb)
    #45 hermes::vm::Interpreter::handleCallSlowPath(hermes::vm::Runtime&, hermes::vm::PinnedHermesValue*) Interpreter.cpp (libhermesvm.so+0x4ac899)
    #46 hermes::vm::CallResult<hermes::vm::HermesValue, (hermes::vm::detail::CallResultSpecialize)2> hermes::vm::Interpreter::interpretFunction<false, false>(hermes::vm::Runtime&, hermes::vm::InterpreterState&) Interpreter.cpp (libhermesvm.so+0x4adc4b)
    #47 hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock*) Interpreter.cpp (libhermesvm.so+0x4aca58)
    #48 hermes::vm::Runtime::interpretFunction(hermes::vm::CodeBlock*) Interpreter.cpp (libhermesvm.so+0x4bb6be)
    #49 hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&) Callable.cpp (libhermesvm.so+0x47ee20)
    #50 facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) hermes.cpp (libhermesvm.so+0x16d73c)
    #51 facebook::jsi::Function::call(facebook::jsi::IRuntime&, facebook::jsi::Value const*, unsigned long) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:325:18 (fantom_tester+0x696b52)
    #52 facebook::jsi::Function::call(facebook::jsi::IRuntime&, std::initializer_list<facebook::jsi::Value>) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:331:10 (fantom_tester+0x696a07)
    #53 facebook::jsi::Value facebook::jsi::Function::call<>(facebook::jsi::IRuntime&) const /react-native/packages/react-native/ReactCommon/jsi/jsi/jsi-inl.h:339:10 (fantom_tester+0x676498)
    #54 facebook::react::TesterAppDelegate::loadScriptAndRunTests(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /react-native/private/react-native-fantom/tester/src/TesterAppDelegate.cpp:200:8 (fantom_tester+0x66ccf3)
    #55 main /react-native/private/react-native-fantom/tester/src/main.cpp:79:15 (fantom_tester+0x71580e)
    #56 main /react-native/private/react-native-fantom/tester/src/main.cpp:58:22 (fantom_tester+0x715621)

SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749:21 in __gthread_mutex_lock(pthread_mutex_t*)
MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/react-native-fantom-reproducer

Screenshots and Videos

No response

Dominant language
C++
Stars
127k
Forks
25.5k
Avg merge
3d 22h
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react/react-native

All issues in react/react-native

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.