Fantom's tester prints no stack when it crashes: it installs no failure signal handler, and its glog config.h compiles the handler and the symbolizer out

Ouverte Adaptée aux débutants
#59,722 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
70/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
android, cpp, linux
Domaine
testing

Piste de recherche

Commencez à partir de private/react-native-fantom/tester/src/main.cpp et packages/react-native/ReactAndroid/src/main/jni/third-party/glog/config.h où l'issue fournit des diffs exacts. Appliquez les trois hunks, puis reconstruisez avec yarn workspace @react-native/fantom build et ./gradlew :private:react-native-fantom:buildFantomTester --rerun. Terminé lorsqu'un crash SIGSEGV imprime des frames nommées tels que faultOnNullWrite().

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Description

When Fantom's tester crashes in native code, the runner reports Command failed (status code: (empty), signal: SIGSEGV) with empty stdout and stderr, so nothing says where it died.

The tester's main initializes glog but never calls google::InstallFailureSignalHandler() (main.cpp L20-L24). Adding the call alone changes nothing: the tester builds glog with the Android config.h (config.h), which never defines HAVE_SIGACTION, and glog 0.3.5's InstallFailureSignalHandler is empty without it (signalhandler.cc L354-L366).

With HAVE_SIGACTION defined, the handler prints the signal, but every frame reads (unknown). The same config.h ends with #undef OS_LINUX (L178-L181). glog's utilities.h defines OS_LINUX from __linux__ (L42), then includes config.h (L81), then defines HAVE_SYMBOLIZE only #if defined(__ELF__) && defined(OS_LINUX) (L125-L126), so Symbolize compiles to its stub on a Linux host.

Defining HAVE_SIGACTION and keeping OS_LINUX (and the syscall headers) when __ANDROID__ is not defined, plus the one call in main, gives a crash report naming each frame's function. The patches in the reproducer show each step:

--- a/private/react-native-fantom/tester/src/main.cpp
+++ b/private/react-native-fantom/tester/src/main.cpp
@@ -21,6 +21,7 @@
   google::InitGoogleLogging("react-native-fantom");
   FLAGS_logtostderr = true;
   FLAGS_minloglevel = AppSettings::minLogLevel;
+  google::InstallFailureSignalHandler();
 }
 
 static void setUpFeatureFlags() {
--- a/packages/react-native/ReactAndroid/src/main/jni/third-party/glog/config.h
+++ b/packages/react-native/ReactAndroid/src/main/jni/third-party/glog/config.h
@@ -64,6 +64,10 @@
 /* Define if you have the `sigaltstack' function */
 #define HAVE_SIGALTSTACK 1
 
+#if !defined(__ANDROID__)
+#define HAVE_SIGACTION 1
+#endif
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1
 
@@ -176,7 +180,9 @@
 
 
 /* TODO(vjn/dreiss): revisit these when use the android-21 (or newer) NDK platform. */
+#if defined(__ANDROID__)
 #undef HAVE_SYSCALL_H
 #undef HAVE_SYS_SYSCALL_H
 #undef OS_LINUX
+#endif
 #undef OS_MACOSX

Under AddressSanitizer or ThreadSanitizer the sanitizer's own report already prints the stack, so the call could be left out of those builds.

Steps to reproduce
  1. git clone https://github.com/YevheniiKotyrlo/react-native-fantom-reproducer && cd react-native-fantom-reproducer

  2. ./fantom/reproduce.sh crash-prints-no-stack (needs Docker). It clones react/react-native at main and builds Fantom's tester as CI does, then:

    1. applies fantom/null-write-in-clear-all-images.patch, which makes NativeFantom::clearAllImages write through a null pointer in a function named faultOnNullWrite, and copies fantom/NativeCrash-itest.js, a test that calls NativeFantom.clearAllImages(), into private/react-native-fantom/src/__tests__/;
    2. runs yarn fantom private/react-native-fantom/src/__tests__/NativeCrash-itest.js on that tester;
    3. applies fantom/install-failure-signal-handler.patch (the main.cpp hunk above), rebuilds and runs the test again;
    4. applies fantom/glog-config-sigaction.patch (HAVE_SIGACTION), rebuilds and runs it again;
    5. applies fantom/glog-config-keep-os-linux.patch (OS_LINUX kept), rebuilds and runs it once more.

    Each rebuild runs ./gradlew :private:react-native-fantom:buildFantomTester --rerun after yarn workspace @react-native/fantom build, since Gradle calls the tester up to date after a change to glog's config.h.

Expected: the crash's report names SIGSEGV and the crashing frame, faultOnNullWrite().

Actual: on main at f1f1474, steps 2 and 3 print stderr: (empty); step 4 prints the signal and 24 frames, each (unknown); only step 5 names faultOnNullWrite(), NativeFantom::clearAllImages() and the frames up to main.

React Native Version

0.88.0 (reproduced on main at f1f1474)

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: 121.74 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
react-native f1f147405888d6ffbcab40e59a05df7aa21ddc7e, committed 2026-10-31T14:33:21+00:00
clang version 23.1.3 (https://github.com/llvm/llvm-project 0d261d1ca552c95a8f007e061c787ac7132fbcbc)
== the stock tester
    Command failed (status code: (empty), signal: SIGSEGV): /react-native/private/react-native-fantom/build/tester/fantom_tester --bundlePath /react-native/private/react-native-fantom/.out/js-builds/run-1793466203344/1793466216285-NativeCrash-itest.js.bundle.js --featureFlags {} --minLogLevel error
    stdout:
    (empty)
    stderr:
    (empty)
== InstallFailureSignalHandler in main
    Command failed (status code: (empty), signal: SIGSEGV): /react-native/private/react-native-fantom/build/tester/fantom_tester --bundlePath /react-native/private/react-native-fantom/.out/js-builds/run-1793466247448/1793466255947-NativeCrash-itest.js.bundle.js --featureFlags {} --minLogLevel error
    stdout:
    (empty)
    stderr:
    (empty)
== and HAVE_SIGACTION in glog's config.h
    Command failed (status code: (empty), signal: SIGSEGV): /react-native/private/react-native-fantom/build/tester/fantom_tester --bundlePath /react-native/private/react-native-fantom/.out/js-builds/run-1793466328130/1793466336202-NativeCrash-itest.js.bundle.js --featureFlags {} --minLogLevel error
    stdout:
    (empty)
    stderr:
    *** Aborted at 1793466337 (unix time) try "date -d @1793466337" if you are using GNU date ***
    PC: @                0x0 (unknown)
    *** SIGSEGV (@0x0) received by PID 12849 (TID 0x7fa6a81aaf00) stack trace: ***
        @     0x7fa6aa33b520 (unknown)
        @     0x5c12e082a256 (unknown)
        @     0x5c12e082a21d (unknown)
        @     0x5c12e0837eac (unknown)
        @     0x5c12e08322e6 (unknown)
        @     0x5c12e083ee70 (unknown)
        @     0x5c12e083ee26 (unknown)
        @     0x5c12e083edb0 (unknown)
        @     0x5c12e083ec70 (unknown)
        @     0x7fa6aaef48d7 (unknown)
        @     0x7fa6ab0b2921 (unknown)
        @     0x7fa6ab0b3230 (unknown)
        @     0x7fa6ab0b2a4f (unknown)
        @     0x7fa6ab097c0d (unknown)
        @     0x7fa6aaee97fb (unknown)
        @     0x5c12e08596f8 (unknown)
        @     0x5c12e0859665 (unknown)
        @     0x5c12e0846b11 (unknown)
        @     0x5c12e084100d (unknown)
        @     0x5c12e08a86a1 (unknown)
        @     0x7fa6aa322d90 (unknown)
        @     0x7fa6aa322e40 (unknown)
        @     0x5c12e0821745 (unknown)
        @                0x0 (unknown)
== and OS_LINUX kept in glog's config.h
    Command failed (status code: (empty), signal: SIGSEGV): /react-native/private/react-native-fantom/build/tester/fantom_tester --bundlePath /react-native/private/react-native-fantom/.out/js-builds/run-1793466481945/1793466501913-NativeCrash-itest.js.bundle.js --featureFlags {} --minLogLevel error
    stdout:
    (empty)
    stderr:
    *** Aborted at 1793466504 (unix time) try "date -d @1793466504" if you are using GNU date ***
    PC: @                0x0 (unknown)
    *** SIGSEGV (@0x0) received by PID 15321 (TID 0x73082173ff00) from PID 0; stack trace: ***
        @     0x7308238d0520 (unknown)
        @     0x58ef9a29c066 facebook::react::faultOnNullWrite()
        @     0x58ef9a29c02d facebook::react::NativeFantom::clearAllImages()
        @     0x58ef9a2a9cbc _ZN8facebook5react8bridging10callFromJsIvNS0_12NativeFantomEvJEJEEET_RNS_3jsi7RuntimeEMT0_FT1_S7_DpT2_ERKSt10shared_ptrINS0_11CallInvokerEEPS8_DpOT3_
        @     0x58ef9a2a40f6 facebook::react::NativeFantomCxxSpec<>::__clearAllImages()
        @     0x58ef9a2b0c80 _ZZN8facebook5react11TurboModule6createERNS_3jsi7RuntimeERKNS2_10PropNameIDEENKUlS4_RKNS2_5ValueEPS9_mE_clES4_SA_SB_m
        @     0x58ef9a2b0c36 _ZSt13__invoke_implIN8facebook3jsi5ValueERZNS0_5react11TurboModule6createERNS1_7RuntimeERKNS1_10PropNameIDEEUlS6_RKS2_PSA_mE_JS6_SB_SC_mEET_St14__invoke_otherOT0_DpOT1_
        @     0x58ef9a2b0bc0 _ZSt10__invoke_rIN8facebook3jsi5ValueERZNS0_5react11TurboModule6createERNS1_7RuntimeERKNS1_10PropNameIDEEUlS6_RKS2_PSA_mE_JS6_SB_SC_mEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESG_E4typeEOSH_DpOSI_
        @     0x58ef9a2b0a80 _ZNSt17_Function_handlerIFN8facebook3jsi5ValueERNS1_7RuntimeERKS2_PS5_mEZNS0_5react11TurboModule6createES4_RKNS1_10PropNameIDEEUlS4_S6_S7_mE_E9_M_invokeERKSt9_Any_dataS4_S6_OS7_Om
        @     0x73082448f8d7 facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::HFContext::func()
        @     0x73082464d921 hermes::vm::Interpreter::handleCallSlowPath()
        @     0x73082464e230 hermes::vm::Interpreter::interpretFunction<>()
        @     0x73082464da4f hermes::vm::Runtime::interpretFunctionImpl()
        @     0x730824632c0d hermes::vm::JSFunction::_callImpl()
        @     0x7308244847fb facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::call()
        @     0x58ef9a2cb508 facebook::jsi::Function::call()
        @     0x58ef9a2cb475 facebook::jsi::Function::call()
        @     0x58ef9a2b8921 _ZNK8facebook3jsi8Function4callIJEEENS0_5ValueERNS0_8IRuntimeEDpOT_
        @     0x58ef9a2b2e1d facebook::react::TesterAppDelegate::loadScriptAndRunTests()
        @     0x58ef9a31a4b1 main
        @     0x7308238b7d90 (unknown)
        @     0x7308238b7e40 __libc_start_main
        @     0x58ef9a293555 _start
        @                0x0 (unknown)
MANDATORY Reproducer

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

Screenshots and Videos

No response

Langage dominant
C++
Étoiles
127k
Forks
25.4k
Merge moyen
2 j 6 h
PR mergées (30 j)
73

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de react/react-native

Toutes les issues de react/react-native

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.