public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Galbraith <efault@gmx.de>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	"nmeyers@vestmark.com" <nmeyers@vestmark.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Major slab mem leak with 2.6.17 / GCC 4.1.1
Date: Sun, 15 Oct 2006 07:59:14 +0000	[thread overview]
Message-ID: <1160899154.5935.19.camel@Homer.simpson.net> (raw)
In-Reply-To: <b0943d9e0610130459w22e6b9a1g57ee67a2c2b97f81@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]

On Fri, 2006-10-13 at 12:59 +0100, Catalin Marinas wrote:
> On 13/10/06, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> > On 10/13/06, nmeyers@vestmark.com <nmeyers@vestmark.com> wrote:
> > > If anyone has a version of kmemleak that I can build with 4.1.1, or
> > > any other suggestions for instrumentation, I'd be happy to gather more
> > > data - the problem is very easy for me to reproduce.
> >
> > You should cc Catalin for that. Alternatively, you could try
> > CONFIG_DEBUG_SLAB_LEAK.
> 
> Thanks for cc'ing me (I'm still on holiday and not following the
> mailing list). The problem is the __builtin_constant_p gcc function
> which doesn't work properly with 4.x versions. It was fixed in latest
> gcc versions though. Kmemleak relies on __builtin_constant_p to
> determine the pointer aliases and without it you would get plenty of
> false positives.

SuSE (for one?) doesn't appear to know about it. gcc version 4.1.2
20060920 (month old prerelease) still has the problem.  After some
rummaging around, I found the fix (attached in case someone else wants
to try it).

2.6.19-rc1 + patch-2.6.19-rc1-kmemleak-0.11 compiles fine now (unless
CONFIG_DEBUG_KEEP_INIT is set), boots and runs too.. but axle grease
runs a lot faster ;-)  I'll try a stripped down config sometime.

	-Mike

[-- Attachment #2: gcc41-rh198849.patch --]
[-- Type: text/x-patch, Size: 2796 bytes --]

2006-06-04  Mark Shinwell  <shinwell codesourcery com>

	* tree.h: Declare folding_initializer.
	* builtins.c (fold_builtin_constant_p): Give definite answer
	if folding inside an initializer.
	* fold-const.c: Define folding_initializer.
	(START_FOLD_INIT): Save and then set folding_initializer.
	(END_FOLD_INIT): Restore folding_initializer.

	* gcc.c-torture/compile/builtin_constant_p.c: New test.

--- gcc/tree.h	(revision 114357)
+++ gcc/tree.h	(revision 114359)
@@ -4142,6 +4142,10 @@ extern void using_eh_for_cleanups (void)
 
 /* In fold-const.c */
 
+/* Non-zero if we are folding constants inside an initializer; zero
+   otherwise.  */
+extern int folding_initializer;
+
 /* Fold constants as much as possible in an expression.
    Returns the simplified expression.
    Acts only on the top level of the expression;
--- gcc/builtins.c	(revision 114357)
+++ gcc/builtins.c	(revision 114359)
@@ -6495,7 +6495,8 @@ fold_builtin_constant_p (tree arglist)
   if (TREE_SIDE_EFFECTS (arglist)
       || AGGREGATE_TYPE_P (TREE_TYPE (arglist))
       || POINTER_TYPE_P (TREE_TYPE (arglist))
-      || cfun == 0)
+      || cfun == 0
+      || folding_initializer)
     return integer_zero_node;
 
   return 0;
--- gcc/fold-const.c	(revision 114357)
+++ gcc/fold-const.c	(revision 114359)
@@ -59,6 +59,10 @@ Software Foundation, 51 Franklin Street,
 #include "langhooks.h"
 #include "md5.h"
 
+/* Non-zero if we are folding constants inside an initializer; zero
+   otherwise.  */
+int folding_initializer = 0;
+
 /* The following constants represent a bit based encoding of GCC's
    comparison operators.  This encoding simplifies transformations
    on relational comparison operators, such as AND and OR.  */
@@ -11708,16 +11712,19 @@ fold_build3_stat (enum tree_code code, t
   int saved_trapping_math = flag_trapping_math;\
   int saved_rounding_math = flag_rounding_math;\
   int saved_trapv = flag_trapv;\
+  int saved_folding_initializer = folding_initializer;\
   flag_signaling_nans = 0;\
   flag_trapping_math = 0;\
   flag_rounding_math = 0;\
-  flag_trapv = 0
+  flag_trapv = 0;\
+  folding_initializer = 1;
 
 #define END_FOLD_INIT \
   flag_signaling_nans = saved_signaling_nans;\
   flag_trapping_math = saved_trapping_math;\
   flag_rounding_math = saved_rounding_math;\
-  flag_trapv = saved_trapv
+  flag_trapv = saved_trapv;\
+  folding_initializer = saved_folding_initializer;
 
 tree
 fold_build1_initializer (enum tree_code code, tree type, tree op)
--- gcc/testsuite/gcc.c-torture/compile/builtin_constant_p.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/builtin_constant_p.c	(revision 114359)
@@ -0,0 +1,8 @@
+/* { dg-options "-O2" } */
+
+int main (int argc, char *argv[])
+{
+  static int a[] = { __builtin_constant_p (argc) ? 1 : 0 };
+  return a[0];
+}
+


  reply	other threads:[~2006-10-15  7:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-13  0:49 Major slab mem leak with 2.6.17 / GCC 4.1.1 nmeyers
2006-10-13  5:56 ` Pekka Enberg
2006-10-13 11:59   ` Catalin Marinas
2006-10-15  7:59     ` Mike Galbraith [this message]
2006-10-15 14:14       ` nmeyers
2006-10-15 17:59         ` Mike Galbraith
2006-10-18 13:59           ` Nathan Meyers
2006-10-16  5:32       ` Mike Galbraith
2006-10-16  8:07         ` Catalin Marinas
2006-10-16  9:08           ` Mike Galbraith
2006-10-16  8:44             ` Catalin Marinas
2006-10-16  9:33               ` Mike Galbraith
2006-10-13  8:25 ` Mike Galbraith
2006-10-13 10:55   ` nmeyers
2006-10-13 21:28     ` Mike Galbraith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1160899154.5935.19.camel@Homer.simpson.net \
    --to=efault@gmx.de \
    --cc=catalin.marinas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nmeyers@vestmark.com \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox