[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Output error message for glibc malloc checking
From:       Michael Pyne <mpyne () kde ! org>
Date:       2009-06-30 1:17:21
Message-ID: 200906292117.28268.mpyne () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi all,

I guess my patch to change MALLOC_CHECK_ to output the error message in 
addition to calling abort() had the effect of spamming the console with tons 
of debugging output as well.

It turns out that the debug message was removed in glibc 2.9 due to complaints 
about it (which is why I didn't notice it -- I'm on 2.10.1).

I didn't want to just give up though as having the actual glibc error printed 
to console is helpful (at least IMO), so I coded up this, which checks if 
glibc is installed and is greater than or equal to version 2.9, otherwise 
leaves MALLOC_CHECK_ at 2.

Two behavior changes are that MALLOC_CHECK_ is only set if glibc is detected 
*AND* if it wasn't already set to a value (before it was unilaterally set to 
2).

I've tried to remain POSIX sh-compatible, please let me know if I've messed 
that up.

The patch is attached.  Any comments?

Regards,
 - Michael Pyne

["startkde-malloc-check.patch" (text/x-patch)]

Index: workspace/startkde.cmake
===================================================================
--- workspace/startkde.cmake	(revision 989338)
+++ workspace/startkde.cmake	(working copy)
@@ -36,10 +36,22 @@
 # we have to unset this for Darwin since it will screw up KDE's dynamic-loading
 unset DYLD_FORCE_FLAT_NAMESPACE
 
-# Enable lightweight memory corruption checker -- this is for trunk only, we remove \
                it for releases
-MALLOC_CHECK_=2
-export MALLOC_CHECK_
+# Enable lightweight memory corruption checker if not already set
+# -- this is for trunk only, we remove it for releases
+if [ "x$MALLOC_CHECK_" = "x" ] && [ -x /lib/libc.so.6 ]; then
+    # Extract the first two components of the version from the output.
+    glibc_version=$(/lib/libc.so.6 | head -1 | sed -e \
's/[^0-9]*\([0-9]\.[0-9]\+\).*/\1/')  
+    MALLOC_CHECK_=2 # Default to 2 unless glibc 2.9 or higher.
+
+    # POSIX test or sh can't do the string compare, use perl
+    # The s/// is to make 2.d$ --> 2.0d$ for sorting.
+    LC_ALL=C perl -e '$vers = $ARGV[0]; $vers =~ s/\.([0-9])$/.0$1/; if ("${vers}" \
ge "2.09") { exit 0; } exit 1;' $glibc_version >/dev/null 2>&1 && { +        \
MALLOC_CHECK_=3 +    }
+    export MALLOC_CHECK_
+fi
+
 # in case we have been started with full pathname spec without being in PATH
 bindir=`echo "$0" | sed -n 's,^\(/.*\)/[^/][^/]*$,\1,p'`
 if [ -n "$bindir" ]; then


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic