Signal handlers - mhahnFr/LeakSanitizer GitHub Wiki
The LeakSanitizer adds a few signal handlers to your program.
Signal handlers installed by your program take precedence over the LeakSanitizer's handlers.
Deadly signals
Upon receipt of a deadly signal, the program is terminated and the callstack of the receiving point is printed. The faulty address is also printed if available.
[!TIP] Example:
Segmentation fault (SIGSEGV) on address 0x0! Address not existent (MAPERR). In: (fdf) get_next_line (bonus/get_next_line_bonus.c:0:37) at: (fdf) generate_read_file (model/generate.c:79:9) at: (fdf) generate_parse_arguments (model/generate.c:21:17) at: (fdf) main (main.c:24:10) at: (/usr/lib/dyld) start + 1903
Caught deadly signals
SIGSEGV
SIGABRT
SIGTERM
SIGALRM
SIGPIPE
SIGFPE
SIGILL
SIGQUIT
SIGHUP
SIGBUS
SIGXFSZ
SIGXCPU
SIGSYS
SIGVTALRM
SIGPROF
SIGTRAP
SIGUSR1
The SIGUSR1
causes the current memory statistics to be printed. It shows you the amount of the currently
allocated objects and the amount of the currently allocated bytes as well as their peek values.
[!TIP] Example:
Stats of the memory usage so far: 297 objects in the heap, peek 661, 485 deleted objects. 7.72 MiB currently used, peek 7.72 MiB. [====================================================================================================] of 7.72 MiB peek 297 objects currently in the heap, peek 661 objects. [=============================================.......................................................] of 661 objects peek
SIGUSR2
The SIGUSR2
causes the callstack of the signal handler to be printed. One can easily see what the application is currently doing
using that callstack.
[!TIP] Example:
The current callstack: In: (fdf) renderer_draw_line (renderer/renderer_draw.c:46:6) at: (fdf) renderer_draw_core (renderer/renderer_draw.c:97:3) at: (fdf) renderer_draw (renderer/renderer_draw.c:24:4) at: (fdf) delegate_render_frame (renderer/renderer.c:14:2) at: (libmlx.dylib) do_loop_hook2 (mlx_init_loop.m:16:3) at: (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation) __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 at: (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation) __CFRunLoopDoTimer + 807 at: (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation) __CFRunLoopDoTimers + 285 at: (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation) __CFRunLoopRun + 2206 at: (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation) CFRunLoopRunSpecific + 560 at: (/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox) RunCurrentEventLoopInMode + 292 at: (/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox) ReceiveNextEventCommon + 657 at: (/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox) _BlockUntilNextEventMatchingListInModeWithFilter + 64 at: (/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit) _DPSNextEvent + 858 at: (/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit) -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1214 at: (/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit) -[NSApplication run] + 586 at: (libmlx.dylib) mlx_loop (mlx_init_loop.m:104:3) at: (fdf) onApplicationFinishedLaunching (delegate/app_delegate.c:36:2) at: (fdf) main (main.c:32:10) at: (/usr/lib/dyld) start + 1903