* [patch] gdb crash in cp_scan_for_anonymous_namespace
@ 2011-10-20 19:33 Aleksandar Ristovski
2011-10-20 19:49 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2011-10-20 19:33 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]
Hello,
I have encountered a gdb crash (gdb 7.3.1 based qnx gdb) in function
cp_scan_for_anonymous_namespace.
What happens is that we get into 'define_symbol' function having an
objfile without any symtabs. cp_scan_for_anonymous_namespaces
dereferences symbol->symtab and crashes gdb.
This is all observed/debugged on gdb7.3.1 code base, but from looking at
HEAD code, the possibility still exists.
I haven't created a testcase yet (the case I have is quite complicated
with numerous shared objects involved and a core).
There are no regressions in existing test suite, tested on
"x86_64-unknown-linux-gnu".
Thanks,
Aleksandar Ristovski
ChangeLog:
2011-10-20 Aleksandar Ristovski <aristovski@qnx.com>
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed
function
arguments by adding OBJFILE. Instead of getting objfile from
symbol's symtab, use new argument OBJFILE.
* cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
arguments by adding OBJFILE.
* gdb/dwarf2read.c (new_symbol_full): Change call to
cp_scan_for_anonymous_namespaces to match new signature.
* gdb/stabsread.c (define_symbol): Change call to
cp_scan_for_anonymous_namespaces to match new signature.
[-- Attachment #2: GDBCRASH-no-symtab-201110201358.patch --]
[-- Type: text/x-patch, Size: 3052 bytes --]
Index: gdb/cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.54
diff -u -p -r1.54 cp-namespace.c
--- gdb/cp-namespace.c 29 Jun 2011 22:05:15 -0000 1.54
+++ gdb/cp-namespace.c 20 Oct 2011 18:26:22 -0000
@@ -53,7 +53,8 @@ static struct type *cp_lookup_transparen
anonymous namespace; if so, add an appropriate using directive. */
void
-cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
+cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
+ struct objfile *const objfile)
{
if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
{
@@ -96,7 +97,7 @@ cp_scan_for_anonymous_namespaces (const
namespace given by the previous component if there is
one, or to the global namespace if there isn't. */
cp_add_using_directive (dest, src, NULL, NULL, NULL,
- &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
+ &objfile->objfile_obstack);
}
/* The "+ 2" is for the "::". */
previous_component = next_component + 2;
Index: gdb/cp-support.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.h,v
retrieving revision 1.45
diff -u -p -r1.45 cp-support.h
--- gdb/cp-support.h 18 Aug 2011 16:17:38 -0000 1.45
+++ gdb/cp-support.h 20 Oct 2011 18:26:22 -0000
@@ -197,7 +197,8 @@ extern void cp_set_block_scope (const st
const char *processing_current_prefix,
int processing_has_namespace_info);
-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
+extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
+ struct objfile *objfile);
extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
const struct block *block,
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.574
diff -u -p -r1.574 dwarf2read.c
--- gdb/dwarf2read.c 17 Oct 2011 12:57:14 -0000 1.574
+++ gdb/dwarf2read.c 20 Oct 2011 18:26:23 -0000
@@ -11936,7 +11936,7 @@ new_symbol_full (struct die_info *die, s
namespaces based on the demangled name. */
if (!processing_has_namespace_info
&& cu->language == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
return (sym);
}
Index: gdb/stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.138
diff -u -p -r1.138 stabsread.c
--- gdb/stabsread.c 18 May 2011 16:30:36 -0000 1.138
+++ gdb/stabsread.c 20 Oct 2011 18:26:23 -0000
@@ -729,7 +729,7 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
p++;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] gdb crash in cp_scan_for_anonymous_namespace
2011-10-20 19:33 [patch] gdb crash in cp_scan_for_anonymous_namespace Aleksandar Ristovski
@ 2011-10-20 19:49 ` Tom Tromey
2011-10-20 20:18 ` Aleksandar Ristovski
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-10-20 19:49 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
>>>>> "Aleksandar" == Aleksandar Ristovski <aristovski@qnx.com> writes:
Aleksandar> I haven't created a testcase yet (the case I have is quite
Aleksandar> complicated with numerous shared objects involved and a
Aleksandar> core).
I think your change is clearly correct, given the comment before
symbol::symtab:
/* The symbol table containing this symbol. This is the file
associated with LINE. It can be NULL during symbols read-in but it is
never NULL during normal operation. */
Aleksandar> 2011-10-20 Aleksandar Ristovski <aristovski@qnx.com>
Aleksandar> * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed
Aleksandar> function
Aleksandar> arguments by adding OBJFILE. Instead of getting objfile from
Aleksandar> symbol's symtab, use new argument OBJFILE.
Aleksandar> * cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
Aleksandar> arguments by adding OBJFILE.
Aleksandar> * gdb/dwarf2read.c (new_symbol_full): Change call to
Aleksandar> cp_scan_for_anonymous_namespaces to match new signature.
Aleksandar> * gdb/stabsread.c (define_symbol): Change call to
Aleksandar> cp_scan_for_anonymous_namespaces to match new signature.
Ok.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] gdb crash in cp_scan_for_anonymous_namespace
2011-10-20 19:49 ` Tom Tromey
@ 2011-10-20 20:18 ` Aleksandar Ristovski
2011-10-20 20:41 ` Aleksandar Ristovski
0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2011-10-20 20:18 UTC (permalink / raw)
To: gdb-patches
On 11-10-20 03:46 PM, Tom Tromey wrote:
> Ok.
>
> Tom
This is now committed:
http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html
Thank you for the quick review,
Aleksandar
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] gdb crash in cp_scan_for_anonymous_namespace
2011-10-20 20:18 ` Aleksandar Ristovski
@ 2011-10-20 20:41 ` Aleksandar Ristovski
2011-10-20 22:09 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2011-10-20 20:41 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
On 11-10-20 04:11 PM, Aleksandar Ristovski wrote:
> On 11-10-20 03:46 PM, Tom Tromey wrote:
>> Ok.
>>
>> Tom
>
> This is now committed:
> http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html
>
> Thank you for the quick review,
>
> Aleksandar
>
Just for completeness sake, here is gdb_7_3-branch patch (the HEAD one
does not cleanly apply, though it is trivial to merge).
Not sure if you want this committed, or just left here for reference, I
don't mind either way.
Thanks,
Aleksandar
[-- Attachment #2: GDBCRASH-no-symtab-201110201358-gdb_7_3-branch.patch --]
[-- Type: text/x-patch, Size: 4071 bytes --]
Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.12887.2.72
diff -u -p -r1.12887.2.72 ChangeLog
--- gdb/ChangeLog 4 Sep 2011 19:11:26 -0000 1.12887.2.72
+++ gdb/ChangeLog 20 Oct 2011 20:29:18 -0000
@@ -1,3 +1,15 @@
+2011-10-20 Aleksandar Ristovski <aristovski@qnx.com>
+
+ * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
+ arguments by adding OBJFILE. Instead of getting objfile from
+ symbol's symtab, use new argument OBJFILE.
+ * cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
+ arguments by adding OBJFILE.
+ * gdb/dwarf2read.c (new_symbol_full): Change call to
+ cp_scan_for_anonymous_namespaces to match new signature.
+ * gdb/stabsread.c (define_symbol): Change call to
+ cp_scan_for_anonymous_namespaces to match new signature.
+
2011-09-04 Joel Brobecker <brobecker@adacore.com>
* version.in: Set version to 7.3.1.20110904-cvs.
Index: gdb/cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.49.2.1
diff -u -p -r1.49.2.1 cp-namespace.c
--- gdb/cp-namespace.c 2 Jul 2011 19:37:21 -0000 1.49.2.1
+++ gdb/cp-namespace.c 20 Oct 2011 20:29:18 -0000
@@ -71,7 +71,8 @@ static void maintenance_cplus_namespace
anonymous namespace; if so, add an appropriate using directive. */
void
-cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
+cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
+ struct objfile *const objfile)
{
if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
{
@@ -114,7 +115,7 @@ cp_scan_for_anonymous_namespaces (const
namespace given by the previous component if there is
one, or to the global namespace if there isn't. */
cp_add_using_directive (dest, src, NULL, NULL,
- &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
+ &objfile->objfile_obstack);
}
/* The "+ 2" is for the "::". */
previous_component = next_component + 2;
Index: gdb/cp-support.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.h,v
retrieving revision 1.41.2.1
diff -u -p -r1.41.2.1 cp-support.h
--- gdb/cp-support.h 2 Jul 2011 19:37:21 -0000 1.41.2.1
+++ gdb/cp-support.h 20 Oct 2011 20:29:19 -0000
@@ -153,7 +153,8 @@ extern void cp_set_block_scope (const st
const char *processing_current_prefix,
int processing_has_namespace_info);
-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
+extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
+ struct objfile *objfile);
extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
const struct block *block,
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.518.2.9
diff -u -p -r1.518.2.9 dwarf2read.c
--- gdb/dwarf2read.c 12 Jul 2011 21:12:56 -0000 1.518.2.9
+++ gdb/dwarf2read.c 20 Oct 2011 20:29:20 -0000
@@ -11445,7 +11445,7 @@ new_symbol_full (struct die_info *die, s
namespaces based on the demangled name. */
if (!processing_has_namespace_info
&& cu->language == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
return (sym);
}
Index: gdb/stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.137
diff -u -p -r1.137 stabsread.c
--- gdb/stabsread.c 15 Mar 2011 17:54:27 -0000 1.137
+++ gdb/stabsread.c 20 Oct 2011 20:29:20 -0000
@@ -729,7 +729,7 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
p++;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] gdb crash in cp_scan_for_anonymous_namespace
2011-10-20 20:41 ` Aleksandar Ristovski
@ 2011-10-20 22:09 ` Tom Tromey
2011-10-25 18:35 ` Aleksandar Ristovski
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-10-20 22:09 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
>>>>> "Aleksandar" == Aleksandar Ristovski <aristovski@qnx.com> writes:
Aleksandar> Not sure if you want this committed, or just left here for
Aleksandar> reference, I don't mind either way.
It is fine by me, go ahead.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] gdb crash in cp_scan_for_anonymous_namespace
2011-10-20 22:09 ` Tom Tromey
@ 2011-10-25 18:35 ` Aleksandar Ristovski
0 siblings, 0 replies; 6+ messages in thread
From: Aleksandar Ristovski @ 2011-10-25 18:35 UTC (permalink / raw)
To: gdb-patches
On 11-10-20 04:58 PM, Tom Tromey wrote:
>>>>>> "Aleksandar" == Aleksandar Ristovski<aristovski@qnx.com> writes:
>
> Aleksandar> Not sure if you want this committed, or just left here for
> Aleksandar> reference, I don't mind either way.
>
> It is fine by me, go ahead.
>
> Tom
Committed to gdb 7.3 branch.
Thanks,
Aleksandar
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-25 18:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-20 19:33 [patch] gdb crash in cp_scan_for_anonymous_namespace Aleksandar Ristovski
2011-10-20 19:49 ` Tom Tromey
2011-10-20 20:18 ` Aleksandar Ristovski
2011-10-20 20:41 ` Aleksandar Ristovski
2011-10-20 22:09 ` Tom Tromey
2011-10-25 18:35 ` Aleksandar Ristovski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox