don't use sigaltstack() with USE_ASAN #2529

This commit is contained in:
nick black 2022-01-05 00:23:11 -05:00
parent 59eb7dd18b
commit 27b5d38ea1
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 10 additions and 7 deletions

View File

@ -428,13 +428,6 @@ If things break or seem otherwise lackluster, **please** consult the
handy if you've got a reference to a valid <code>nccell</code> anyway. handy if you've got a reference to a valid <code>nccell</code> anyway.
</details> </details>
<details>
<summary>I compiled with AddressSanitizer, and ASAN throws an exception on
program exit.</summary>
Yeah, I think it has something to do with our signal handling, don't know
yet, sorry.
</details>
<details> <details>
<summary>I ran my Notcurses program under <code>valgrind</code>/ASAN, and <summary>I ran my Notcurses program under <code>valgrind</code>/ASAN, and
it shows memory leaks from <code>libtinfo.so</code>, what's up with that?</summary> it shows memory leaks from <code>libtinfo.so</code>, what's up with that?</summary>

View File

@ -205,6 +205,10 @@ int setup_signals(void* vnc, bool no_quit_sigs, bool no_winch_sigs,
handling_winch = true; handling_winch = true;
} }
if(!no_quit_sigs){ if(!no_quit_sigs){
// AddressSanitizer doesn't want us to use sigaltstack(). we could force everyone
// to export ASAN_OPTIONS=use_sigaltstack=0, or just not fuck with the alternate
// signal stack when built with ASAN.
#ifndef USE_ASAN
alt_signal_stack.ss_sp = malloc(alt_signal_stack.ss_size); alt_signal_stack.ss_sp = malloc(alt_signal_stack.ss_size);
if(alt_signal_stack.ss_sp == NULL){ if(alt_signal_stack.ss_sp == NULL){
fprintf(stderr, "warning: couldn't create alternate signal stack (%s)" NL, strerror(errno)); fprintf(stderr, "warning: couldn't create alternate signal stack (%s)" NL, strerror(errno));
@ -217,6 +221,7 @@ int setup_signals(void* vnc, bool no_quit_sigs, bool no_winch_sigs,
alt_signal_stack.ss_sp = NULL; alt_signal_stack.ss_sp = NULL;
} }
} }
#endif
memset(&sa, 0, sizeof(sa)); memset(&sa, 0, sizeof(sa));
fatal_callback = handler; fatal_callback = handler;
sa.sa_sigaction = fatal_handler; sa.sa_sigaction = fatal_handler;

View File

@ -1,5 +1,10 @@
// Populated by CMake; not installed // Populated by CMake; not installed
// if we're a DFSG build, we leave out references to certain demos
#cmakedefine DFSG_BUILD #cmakedefine DFSG_BUILD
// if we're an ASAN build, we don't use sigaltstack() ourselves
#cmakedefine USE_ASAN
#cmakedefine USE_DEFLATE #cmakedefine USE_DEFLATE
#cmakedefine USE_GPM #cmakedefine USE_GPM
#cmakedefine USE_QRCODEGEN #cmakedefine USE_QRCODEGEN