5

I compiled my code with -fsanitize=address on centOS 7.2.1511. When I updated gcc to 7.1.0, it can't generate core dump file anymore. Can anybody help me?

gcc compile options:

-lm -g3 -Wall -Wno-unknown-pragmas --std=c++11 -Werror -ggdb -fsanitize=address -fno-omit-frame-pointer -D_GLIBCXX_USE_CXX11_ABI=0

link options:

-lxml2 -lpthread -lmysqlclient -L/usr/lib64/mysql/ -llog4cxx -lprotobuf -llua -lluabind -lhiredis -lcrypto -lcurl -ljsoncpp -Wl,-E -fsanitize=address -ldl

When I used gcc 4.8.5, core dump was normally generated with the option ASAN_OPTIONS set like this:

export ASAN_OPTIONS="disable_core=0:unmap_shadow_on_exit=1:abort_on_error=1"

When I updated gcc to 7.1.0, core dump can't generate anymore, even if the ASAN_OPTIONS is set like above.

ks1322
  • 33,961
  • 14
  • 109
  • 164
WenJuan Wu
  • 99
  • 1
  • 7

2 Answers2

4

Problem is solved.The new sanitizer option ASAN_OPTIONS should be set is "disable_coredump",I set it like this:

ASAN_OPTIONS="disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=1"
ulidtko
  • 14,740
  • 10
  • 56
  • 88
WenJuan Wu
  • 99
  • 1
  • 7
1

Well, in theory it should've worked like this:

  1. ulimit -c unlimited of course (optionally adjust sysctl kernel.core_pattern)
  2. export ASAN_OPTIONS=disable_coredump=0,abort_on_error=1
  3. run, obtain the core (ideally, if all works).

However, I've tried quite a few more combinations of disable_coredump=0, halt_on_error=1, abort_on_error=1, handle_abort=0 -- all I got each time was just an annoying ASAN error (@ LLVM 8, commit 1473e85213404eccb4d018d41c24d2f5834f81b5):

nested bug in the same thread, aborting.

and exit code 1 (no core). From what little glimpses at the source that I've taken, it seems that asan handles that same SIGABRT that it emitted, but interpreting that as a crash-while-handling-a-crash. Not quite exactly what -help said; a thing to improve, perhaps.


Still, I was able to circumvent this itchy-bitchy error handling with one more option:

ASAN_OPTIONS+=:sleep_before_dying=150

and then, when it sleeped as instructed, hit ^\ in the terminal (Ctrl\, the equivalent of kill -QUIT).

That, finally, produced the core file I've been trying to get.

ulidtko
  • 14,740
  • 10
  • 56
  • 88
  • Thank you! Still hitting this "nested bug in the same thread" thing in gcc 8.3.1. I was beginning to go a little crazy. :-( – Mike Andrews Jul 22 '20 at 18:57
  • 1
    @MikeAndrews welcome! :) Let me suggest to channel that frustration into a constructive bug report, *"abort_on_error doesn't work"* or something similar. https://github.com/google/sanitizers/issues might be a good starting point. – ulidtko Jul 23 '20 at 08:41
  • 1
    Already reported here https://github.com/google/sanitizers/issues/1072 – user7610 Mar 05 '22 at 22:37