]> git.sur5r.net Git - i3/i3/commitdiff
ASAN: trigger leak before exiting
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 9 Jan 2016 16:18:05 +0000 (17:18 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 9 Jan 2016 16:18:05 +0000 (17:18 +0100)
This disables the default leak-check-on-exit behavior which reports a
bunch of leaks that are only leaks while exiting, at which point they
don’t matter, because the operating system will clean up the memory our
process used.

i3bar/src/ipc.c
i3bar/src/xcb.c
src/commands.c
src/restore_layout.c

index 1214954d109c9afa66423995e96c18698b730772..3489866301183377627a8d5555abf6d5251634b9 100644 (file)
@@ -17,6 +17,9 @@
 #include <sys/un.h>
 #include <i3/ipc.h>
 #include <ev.h>
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
 
 #include "common.h"
 
@@ -212,6 +215,9 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
             /* EOF received. Since i3 will restart i3bar instances as appropriate,
              * we exit here. */
             DLOG("EOF received, exiting...\n");
+#ifdef I3_ASAN_ENABLED
+            __lsan_do_leak_check();
+#endif
             clean_xcb();
             exit(EXIT_SUCCESS);
         }
index 590515a77db54c588374b2fb57719d240b84e164..0b9f094bdbe2859026e65271741540abe80d37eb 100644 (file)
 #include <X11/XKBlib.h>
 #include <X11/extensions/XKB.h>
 
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
+
 #include "common.h"
 #include "libi3.h"
 
@@ -1070,6 +1074,9 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
 
     if (xcb_connection_has_error(xcb_connection)) {
         ELOG("X11 connection was closed unexpectedly - maybe your X server terminated / crashed?\n");
+#ifdef I3_ASAN_ENABLED
+        __lsan_do_leak_check();
+#endif
         exit(1);
     }
 
index 515b57760fdd8dff6694d43991cccc9f0f06170d..525a30fceef2e7e681887f51f4940fc14d92bf66 100644 (file)
 #include <float.h>
 #include <stdarg.h>
 
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
+
 #include "all.h"
 #include "shmlog.h"
 
@@ -1658,6 +1662,9 @@ void cmd_layout_toggle(I3_CMD, const char *toggle_mode) {
  */
 void cmd_exit(I3_CMD) {
     LOG("Exiting due to user command.\n");
+#ifdef I3_ASAN_ENABLED
+    __lsan_do_leak_check();
+#endif
     ipc_shutdown();
     unlink(config.ipc_socket_path);
     xcb_disconnect(conn);
index 4b9dc4ae560361412bc72abb1d3bfb1b7344a8cb..7e1b78aec525bbae4d5622856ed3d0b5472a46d4 100644 (file)
  */
 #include "all.h"
 
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
+
 typedef struct placeholder_state {
     /** The X11 placeholder window. */
     xcb_window_t window;
@@ -114,6 +118,9 @@ void restore_connect(void) {
         if (restore_conn != NULL) {
             xcb_disconnect(restore_conn);
         }
+#ifdef I3_ASAN_ENABLED
+        __lsan_do_leak_check();
+#endif
         errx(EXIT_FAILURE, "Cannot open display\n");
     }