From 2ae06df58f5f5eaf4386c14d28af25b643401bf3 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 11 Nov 2021 08:56:11 -0800 Subject: [PATCH] Let react_native_assert really abort the app Summary: Fixed a bug in `react_native_assert` that was not effectively letting the app call `abort()`. The app was actually printing on log twice. Ref: https://developer.android.com/ndk/reference/group/logging#__android_log_assert Changelog: [Android] [Changed] - Let react_native_assert really abort the app Reviewed By: JoshuaGross Differential Revision: D32204080 fbshipit-source-id: ca16c50aaf4e41a2318277c233be0e944b2ad8f1 --- ReactCommon/react/debug/react_native_assert.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactCommon/react/debug/react_native_assert.cpp b/ReactCommon/react/debug/react_native_assert.cpp index a72b91aecc6121..ad31536726f450 100644 --- a/ReactCommon/react/debug/react_native_assert.cpp +++ b/ReactCommon/react/debug/react_native_assert.cpp @@ -22,7 +22,7 @@ extern "C" void react_native_assert_fail( const char *file, int line, const char *expr) { - // Print as an error so it shows up in logcat before crash.... + // Print as an error so it shows up in logcat before crash... __android_log_print( ANDROID_LOG_ERROR, "ReactNative", @@ -31,9 +31,9 @@ extern "C" void react_native_assert_fail( line, func, expr); - // Print as a fatal so it crashes and shows up in uploaded logs - __android_log_print( - ANDROID_LOG_FATAL, + // ...and trigger an abort so it crashes and shows up in uploaded logs. + __android_log_assert( + nullptr, "ReactNative", "%s:%d: function %s: assertion failed (%s)", file,