Gcc sanitizer: unmap_shadow_on_exit is not executed using the special SIGSEGV handler

GCC sanitizer on 64-bit systems creates huge kernel files of about 17 TB.

If you need a kernel for analysis after death, you need to pass the following parameters for the disinfectant:

  • unmap_shadow_on_exit = 1 - cancels the huge memory used to store output at home

  • disable_core = 0 - created kernel files on a 64-bit system

    However, if you process SIGSEGV with your own signal handler, unmap_shadow_on_exit does not work and a huge kernel file is created.

Any ideas how to get unmap_shadow_on_exit to do the job?

+7
gcc memory-management debugging
source share
1 answer

The regular signal handler is not lost, but returned when you install the client handler - therefore, it can work, just call this code as part of your own signal handler after you finish with any functionality available in your own handler.

So something like:

sighandler_t oldSigHandler = 0; void mySigHandler(int sig) { ... your code ... if (oldSigHandler) oldSigHandler(sig); } void setMySignalHandler(int sig) { oldSigHandler = signal(sig, mySigHandler); } 

I usually perceive signal handlers as evil and try to avoid them, but this may work for you.

Alternatively, if you just want to avoid the kernel dump file, you can try to limit the allowed size of the kernel dump using ulimit -c from the shell or from your own code - however, the main files truncated in this way do not always work with gdb , which you need.

+3
source share

All Articles