[Patch] Some fixes to awesome_atexit()

2009-09-04 Thread Uli Schlachter
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi,

First patch fixes some valgrind invalid access errors and second one fixes a
valgrind leaked fd warning (libev leaked its epoll and signalfd file 
descriptors).

Uli
- --
Do you know that books smell like nutmeg or some spice from a foreign land?
  -- Faber in Fahrenheit 451
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iQEcBAEBCAAGBQJKoRMQAAoJECLkKOvLj8sGKKcH/R5ad6q+GO5bcIju+S9RVXq0
sH2FfdTaxVdhHNfACAXkrz2ScOmhQgY0ucToz2IbODBWsPkBsGQphlhnmXpZ1BfA
Bb3576DkNVXSG7uleQs+g7u2yDu6KoL3Srcb9gVffR0QfZStg6cctypHe61Eb0+j
a/cHUkTPsHiNcbth7xeva5deBZLV7adbjCwQigfS/l5p4b4kVjgL6WWJmzUiJ/Ej
5JO4cEdTTDuZydbOWsRbOJE/GlhTxcykeUJyfAb2czlyd3Qgk8AMh9xCeXWA2p0+
WSP8pbVb5En3bjH5vAL1dpSdFuKqXfXJZ5U59eK7yqM58j+D8AIjGM0SLZaZIQk=
=iYb8
-END PGP SIGNATURE-
From 4be181e5ebbcd4ede6dc2464e677b3387b5c5513 Mon Sep 17 00:00:00 2001
From: Uli Schlachter psyc...@znc.in
Date: Fri, 4 Sep 2009 15:10:56 +0200
Subject: [PATCH 1/2] Disconnect from the X server after closing lua

Else stuff like this can happen:

  Invalid read of size 4:
at 0x300280BB7F: (within /usr/lib/libxcb.so.1.1.0)
by 0x300280BD21: xcb_get_extension_data (in /usr/lib/libxcb.so.1.1.0)
by 0x300280A55A: xcb_send_request (in /usr/lib/libxcb.so.1.1.0)
by 0x300C604A4F: xcb_render_free_picture (in /usr/lib/libxcb-render.so.0.0.0)
by 0x300B24C4BB: (within /usr/lib/libcairo.so.2.10800.8)
by 0x300B22F1B6: cairo_surface_finish (in /usr/lib/libcairo.so.2.10800.8)
by 0x300B22F234: cairo_surface_destroy (in /usr/lib/libcairo.so.2.10800.8)
by 0x300B218124: (within /usr/lib/libcairo.so.2.10800.8)
by 0x300B212750: cairo_destroy (in /usr/lib/libcairo.so.2.10800.8)
by 0x42E4D0: wibox_wipe (draw.h:110)
by 0x42E568: luaA_wibox_gc (wibox.c:46)
by 0x3008E0CB15: (within /usr/lib/liblua5.1.so.0.0.0)
  Address 0x4e56ec0 is 20,928 bytes inside a block of size 20,992 free'd
at 0x4A0761F: free (vg_replace_malloc.c:323)
by 0x40F974: awesome_atexit (awesome.c:97)
by 0x410316: main (awesome.c:577)

Signed-off-by: Uli Schlachter psyc...@znc.in
---
 awesome.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/awesome.c b/awesome.c
index 157880d..37684a7 100644
--- a/awesome.c
+++ b/awesome.c
@@ -92,12 +92,13 @@ awesome_atexit(void)
 titlebar_client_detach(*c);
 }
 
+/* Close Lua */
+lua_close(globalconf.L);
+
 xcb_flush(globalconf.connection);
 
+/* Disconnect *after* closing lua */
 xcb_disconnect(globalconf.connection);
-
-/* Close Lua */
-lua_close(globalconf.L);
 }
 
 /** Scan X to find windows to manage.
-- 
1.6.3.3

From d12296ee229a675d49e67e105a5806cd0003c961 Mon Sep 17 00:00:00 2001
From: Uli Schlachter psyc...@znc.in
Date: Fri, 4 Sep 2009 15:14:07 +0200
Subject: [PATCH 2/2] awesome_atexit(): Clean up libev's state

Signed-off-by: Uli Schlachter psyc...@znc.in
---
 awesome.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/awesome.c b/awesome.c
index 37684a7..60da046 100644
--- a/awesome.c
+++ b/awesome.c
@@ -99,6 +99,8 @@ awesome_atexit(void)
 
 /* Disconnect *after* closing lua */
 xcb_disconnect(globalconf.connection);
+
+ev_default_destroy();
 }
 
 /** Scan X to find windows to manage.
-- 
1.6.3.3



Re: [Patch] Some fixes to awesome_atexit()

2009-09-04 Thread Julien Danjou
At 1252070161 time_t, Uli Schlachter wrote:
 First patch fixes some valgrind invalid access errors and second one fixes a
 valgrind leaked fd warning (libev leaked its epoll and signalfd file 
 descriptors).

Good catch, all in!

Cheers,
-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Trust no one.


signature.asc
Description: Digital signature