Skip to content

Commit be2226b

Browse files
Nathan Riccimarek-safar
authored andcommitted
Revert "[crashing] Improve crash chaining (#19973)"
This reverts commit 7a0425e. This change was causing this android issue: #20275
1 parent cdeef84 commit be2226b

File tree

9 files changed

+50
-38
lines changed

9 files changed

+50
-38
lines changed

mono/mini/exceptions-amd64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
6666
#endif
6767

6868
if (mono_dump_start ())
69-
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL, NULL);
69+
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL);
7070

7171
return EXCEPTION_CONTINUE_SEARCH;
7272
}
@@ -876,7 +876,7 @@ altstack_handle_and_restore (MonoContext *ctx, MonoObject *obj, guint32 flags)
876876

877877
if (!ji || (!stack_ovf && !nullref)) {
878878
if (mono_dump_start ())
879-
mono_handle_native_crash (mono_get_signame (SIGSEGV), ctx, NULL, NULL);
879+
mono_handle_native_crash (mono_get_signame (SIGSEGV), ctx, NULL);
880880
// if couldn't dump or if mono_handle_native_crash returns, abort
881881
abort ();
882882
}

mono/mini/exceptions-ppc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s
676676
}
677677
if (!ji)
678678
if (mono_dump_start ())
679-
mono_handle_native_crash (mono_get_signame (SIGSEGV), (MonoContext*)sigctx, siginfo, sigctx);
679+
mono_handle_native_crash (mono_get_signame (SIGSEGV), (MonoContext*)sigctx, siginfo);
680680
/* setup a call frame on the real stack so that control is returned there
681681
* and exception handling can continue.
682682
* The frame looks like:

mono/mini/exceptions-x86.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
6767
}
6868
#endif
6969
if (mono_dump_start ())
70-
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL, NULL);
70+
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL);
7171

7272
return EXCEPTION_CONTINUE_SEARCH;
7373
}
@@ -1140,7 +1140,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s
11401140
MonoContext mctx;
11411141
mono_sigctx_to_monoctx (sigctx, &mctx);
11421142
if (mono_dump_start ())
1143-
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, siginfo, sigctx);
1143+
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, siginfo);
11441144
else
11451145
abort ();
11461146
}

mono/mini/mini-exceptions.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,7 +3374,7 @@ print_stack_frame_to_string (StackFrameInfo *frame, MonoContext *ctx, gpointer d
33743374
* printing diagnostic information and aborting.
33753375
*/
33763376
void
3377-
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, void *context)
3377+
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
33783378
{
33793379
MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
33803380

@@ -3384,20 +3384,17 @@ mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLE
33843384
sigemptyset (&sa.sa_mask);
33853385
sa.sa_flags = 0;
33863386

3387-
/* Mono has crashed - remove our handlers except SIGTERM, which is used by crash reporting */
3388-
/* TODO: Combine with mono_runtime_cleanup_handlers (but with an option to not de-allocate anything) */
3389-
if (mini_debug_options.handle_sigint) {
3390-
g_assert (sigaction (SIGINT, &sa, NULL) != -1);
3391-
}
3392-
3387+
/* Remove our SIGABRT handler */
33933388
g_assert (sigaction (SIGABRT, &sa, NULL) != -1);
3394-
g_assert (sigaction (SIGFPE, &sa, NULL) != -1);
3395-
g_assert (sigaction (SIGSYS, &sa, NULL) != -1);
3396-
g_assert (sigaction (SIGSEGV, &sa, NULL) != -1);
3397-
g_assert (sigaction (SIGQUIT, &sa, NULL) != -1);
3398-
g_assert (sigaction (SIGBUS, &sa, NULL) != -1);
3389+
3390+
/* On some systems we get a SIGILL when calling abort (), because it might
3391+
* fail to raise SIGABRT */
33993392
g_assert (sigaction (SIGILL, &sa, NULL) != -1);
3393+
3394+
/* Remove SIGCHLD, it uses the finalizer thread */
34003395
g_assert (sigaction (SIGCHLD, &sa, NULL) != -1);
3396+
3397+
/* Remove SIGQUIT, we are already dumping threads */
34013398
g_assert (sigaction (SIGQUIT, &sa, NULL) != -1);
34023399

34033400
#endif
@@ -3437,13 +3434,13 @@ mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLE
34373434
g_async_safe_printf ("=================================================================\n");
34383435
}
34393436

3440-
mono_post_native_crash_handler (signal, mctx, info, mono_do_crash_chaining, context);
3437+
mono_post_native_crash_handler (signal, mctx, info, mono_do_crash_chaining);
34413438
}
34423439

34433440
#else
34443441

34453442
void
3446-
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, void *context)
3443+
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
34473444
{
34483445
g_assert_not_reached ();
34493446
}

mono/mini/mini-posix.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ MONO_SIG_HANDLER_FUNC (static, sigabrt_signal_handler)
231231
return;
232232
mono_sigctx_to_monoctx (ctx, &mctx);
233233
if (mono_dump_start ())
234-
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info, ctx);
234+
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info);
235235
else
236236
abort ();
237237
}
@@ -253,7 +253,7 @@ MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
253253
// running. Returns FALSE on unrecoverable error.
254254
if (mono_dump_start ()) {
255255
// Process was killed from outside since crash reporting wasn't running yet.
256-
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, NULL, ctx);
256+
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, NULL);
257257
} else {
258258
// Crash reporting already running and we got a second SIGTERM from as part of thread-summarizing
259259
if (!mono_threads_summarize_execute (&mctx, &output, &hashes, FALSE, NULL, 0))
@@ -1158,7 +1158,7 @@ mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HAN
11581158
}
11591159

11601160
void
1161-
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context)
1161+
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining)
11621162
{
11631163
if (!crash_chaining) {
11641164
/*Android abort is a fluke, it doesn't abort, it triggers another segv. */
@@ -1168,11 +1168,6 @@ mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_
11681168
abort ();
11691169
#endif
11701170
}
1171-
mono_chain_signal (info->si_signo, info, context);
1172-
1173-
// we remove Mono's signal handlers from crashing signals in mono_handle_native_crash(), so re-raising will now allow the OS to handle the crash
1174-
// TODO: perhaps we can always use this to abort, instead of explicit exit()/abort() as we do above
1175-
raise (info->si_signo);
11761171
}
11771172
#endif /* !MONO_CROSS_COMPILE */
11781173

mono/mini/mini-runtime.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,8 +3228,11 @@ MONO_SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
32283228

32293229
mono_sigctx_to_monoctx (ctx, &mctx);
32303230
if (mono_dump_start ())
3231-
mono_handle_native_crash (mono_get_signame (SIGFPE), &mctx, info, ctx);
3232-
goto exit;
3231+
mono_handle_native_crash (mono_get_signame (SIGFPE), &mctx, info);
3232+
if (mono_do_crash_chaining) {
3233+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
3234+
goto exit;
3235+
}
32333236
}
32343237

32353238
mono_arch_handle_exception (ctx, exc);
@@ -3250,10 +3253,14 @@ MONO_SIG_HANDLER_FUNC (, mono_crashing_signal_handler)
32503253
mono_sigctx_to_monoctx (ctx, &mctx);
32513254
if (mono_dump_start ())
32523255
#if defined(HAVE_SIG_INFO) && !defined(HOST_WIN32) // info is a siginfo_t
3253-
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info, ctx);
3256+
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info);
32543257
#else
3255-
mono_handle_native_crash (mono_get_signame (SIGTERM), &mctx, info, ctx);
3258+
mono_handle_native_crash (mono_get_signame (SIGTERM), &mctx, info);
32563259
#endif
3260+
if (mono_do_crash_chaining) {
3261+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
3262+
return;
3263+
}
32573264
}
32583265

32593266
#if defined(MONO_ARCH_USE_SIGACTION) || defined(HOST_WIN32)
@@ -3333,7 +3340,11 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
33333340
if (!mono_do_crash_chaining && mono_chain_signal (MONO_SIG_HANDLER_PARAMS))
33343341
return;
33353342
if (mono_dump_start())
3336-
mono_handle_native_crash (mono_get_signame (signo), &mctx, info, ctx);
3343+
mono_handle_native_crash (mono_get_signame (signo), &mctx, info);
3344+
if (mono_do_crash_chaining) {
3345+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
3346+
return;
3347+
}
33373348
}
33383349
#endif
33393350

@@ -3372,7 +3383,7 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
33723383
} else {
33733384
// FIXME: This shouldn't run on the altstack
33743385
if (mono_dump_start ())
3375-
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, info, ctx);
3386+
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, info);
33763387
}
33773388
#endif
33783389
}
@@ -3383,14 +3394,23 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
33833394
return;
33843395

33853396
if (mono_dump_start ())
3386-
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info, ctx);
3397+
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
3398+
3399+
if (mono_do_crash_chaining) {
3400+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
3401+
return;
3402+
}
33873403
}
33883404

33893405
if (mono_is_addr_implicit_null_check (fault_addr)) {
33903406
mono_arch_handle_exception (ctx, NULL);
33913407
} else {
33923408
if (mono_dump_start ())
3393-
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info, ctx);
3409+
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
3410+
if (mono_do_crash_chaining) {
3411+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
3412+
return;
3413+
}
33943414
}
33953415
#endif
33963416
}

mono/mini/mini-runtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void
556556
mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info);
557557

558558
void
559-
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context);
559+
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining);
560560

561561
gboolean
562562
mono_is_addr_implicit_null_check (void *addr);

mono/mini/mini-windows.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HAN
281281
}
282282

283283
void
284-
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context)
284+
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining)
285285
{
286286
if (!crash_chaining)
287287
abort ();

mono/mini/mini.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2503,7 +2503,7 @@ typedef gboolean (*MonoJitStackWalk) (StackFrameInfo *frame, MonoCont
25032503

25042504
void mono_exceptions_init (void);
25052505
gboolean mono_handle_exception (MonoContext *ctx, gpointer obj);
2506-
void mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo, void *context);
2506+
void mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo);
25072507
MONO_API void mono_print_thread_dump (void *sigctx);
25082508
MONO_API void mono_print_thread_dump_from_ctx (MonoContext *ctx);
25092509
void mono_walk_stack_with_ctx (MonoJitStackWalk func, MonoContext *start_ctx, MonoUnwindOptions unwind_options, void *user_data);

0 commit comments

Comments
 (0)