This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Regression for gdb.stabs/gdb11479.exp [Re: [patch 1/2] Use custom hash function with bcache]


> As far as I can tell, it looks like there is either a memory
> corruption somewhere, or we fail to set a field in the psymbol
> ginfo. We iterate over all psymbols, and the associated gsym
> has an invalid obj_section.
> 

Yup exactly. This part of the patch caused the problem:

>   /* Helper function, initialises partial symbol structure and stashes
>      it into objfile's bcache.  Note that our caching mechanism will
>      use all fields of struct partial_symbol to determine hash value of the
> @@ -1285,15 +1326,8 @@ add_psymbol_to_bcache (char *name, int namelength, int copy_name,
>   		       enum language language, struct objfile *objfile,
>   		       int *added)
>   {
> -  /* psymbol is static so that there will be no uninitialized gaps in the
> -     structure which might contain random data, causing cache misses in
> -     bcache. */
> -  static struct partial_symbol psymbol;
> -

I thought this was OK because the new hash function looked only at the
initialized fields. Of course this left obj_section uninitialized.
Adding:

  memset (&psymbol, 0, sizeof (psymbol));

seems to fix the problem:

Running ../../../gdb/testsuite/gdb.ada/complete.exp ...
Running ../../../gdb/testsuite/gdb.stabs/gdb11479.exp ...

		=== gdb Summary ===

# of expected passes		39

The problem with my testing is that my script did not look for the word
ERROR in the log file.

The attached patch has been regression tested on F13 gcc 4.4.4... 
properly :)


Fix custom hash regression.

2010-09-01  Sami Wagiaalla  <swagiaal@redhat.com>

	* psymtab.c (add_psymbol_to_bcache): memset psymbol to 0
	before initializing individual fields.

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index a5d2f98..a8b63f7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1378,6 +1378,8 @@ add_psymbol_to_bcache (char *name, int namelength, int copy_name,
 {
   struct partial_symbol psymbol;
 
+  memset (&psymbol, 0, sizeof (psymbol));
+
   /* val and coreaddr are mutually exclusive, one of them *will* be zero */
   if (val != 0)
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]