From eb9ab3108cc5b5cdb7e5ea3518e4417c27c1209c Mon Sep 17 00:00:00 2001 From: Viktor Stanchev Date: Fri, 28 Mar 2014 16:06:18 -0400 Subject: [PATCH] Bug 984196 - glxtest should use _exit instead of exit. r=bgirard --HG-- extra : rebase_source : 3bba6badd7e5a4031ad402cf88f7e0a15f4ba386 --- build/valgrind/i386-redhat-linux-gnu.sup | 12 ++++++++++++ build/valgrind/x86_64-redhat-linux-gnu.sup | 12 ++++++++++++ toolkit/xre/glxtest.cpp | 17 +++++++++++++---- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/build/valgrind/i386-redhat-linux-gnu.sup b/build/valgrind/i386-redhat-linux-gnu.sup index 828db356092..c1d39cd2448 100644 --- a/build/valgrind/i386-redhat-linux-gnu.sup +++ b/build/valgrind/i386-redhat-linux-gnu.sup @@ -49,3 +49,15 @@ obj:/lib/libgobject-2.0.so.0.2200.5 ... } + +################################### +# Leaks in short lived precesses # +################################### + +{ + Bug 984196 + Memcheck:Leak + ... + fun:glxtest + ... +} diff --git a/build/valgrind/x86_64-redhat-linux-gnu.sup b/build/valgrind/x86_64-redhat-linux-gnu.sup index 947cb4d5134..17c2ad47227 100644 --- a/build/valgrind/x86_64-redhat-linux-gnu.sup +++ b/build/valgrind/x86_64-redhat-linux-gnu.sup @@ -71,3 +71,15 @@ fun:gdk_display_open ... } + +################################### +# Leaks in short lived precesses # +################################### + +{ + Bug 984196 + Memcheck:Leak + ... + fun:glxtest + ... +} diff --git a/toolkit/xre/glxtest.cpp b/toolkit/xre/glxtest.cpp index bfdb79600f5..b8681ad9ad9 100644 --- a/toolkit/xre/glxtest.cpp +++ b/toolkit/xre/glxtest.cpp @@ -83,7 +83,7 @@ static void fatal_error(const char *str) { write(write_end_of_the_pipe, str, strlen(str)); write(write_end_of_the_pipe, "\n", 1); - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } static int @@ -97,11 +97,18 @@ x_error_handler(Display *, XErrorEvent *ev) ev->request_code, ev->minor_code); write(write_end_of_the_pipe, buf, length); - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); return 0; } -static void glxtest() + +// glxtest is declared inside extern "C" so that the name is not mangled. +// The name is used in build/valgrind/x86_64-redhat-linux-gnu.sup to suppress +// memory leak errors because we run it inside a short lived fork and we don't +// care about leaking memory +extern "C" { + +void glxtest() { // we want to redirect to /dev/null stdout, stderr, and while we're at it, // any PR logging file descriptors. To that effect, we redirect all positive @@ -245,6 +252,8 @@ static void glxtest() write(write_end_of_the_pipe, buf, length); } +} + /** \returns true in the child glxtest process, false in the parent process */ bool fire_glxtest_process() { @@ -267,7 +276,7 @@ bool fire_glxtest_process() write_end_of_the_pipe = pfd[1]; glxtest(); close(pfd[1]); - exit(0); + _exit(0); } close(pfd[1]);