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: [patch] Fix a crash when displaying variables from shared library.


On Tue, Feb 10, 2009 at 5:43 PM, Tom Tromey <tromey@redhat.com> wrote:

> But, it seems to me that notifying the observer here is the right
> thing to do -- otherwise this observer is unreliable.

Vladimir beat me to it.

> This patch is ok.

It turns out that clearing all displays on solib unload was too
aggressive, as can be seen here:

/* --- noshlib.c --- */
int a_global;
int foo()
{
    static int a_static;
    int a_local;
    return a_global + a_local + a_static;
}

int main()
{
    return foo();
}
/* --- cut --- */

Before the patch:

gdb64-cvs -nx -ex 'set confirm off' ./noshlib
GNU gdb (GDB) 6.8.50.20090218-cvs
...
(gdb) b main
Breakpoint 1 at 0x40032a: file noshlib.c, line 11.
(gdb) b foo
Breakpoint 2 at 0x400310: file noshlib.c, line 6.
(gdb) r

Breakpoint 1, main () at noshlib.c:11
11          return foo();
(gdb) c

Breakpoint 2, foo () at noshlib.c:6
6           return a_global + a_local + a_static;
(gdb) display a_global
(gdb) display a_local
(gdb) display a_static
(gdb) r

Breakpoint 1, main () at noshlib.c:11
11          return foo();
3: a_static = 0
1: a_global = 0
(gdb) c

Breakpoint 2, foo () at noshlib.c:6
6           return a_global + a_local + a_static;
3: a_static = 0
2: a_local = 0
1: a_global = 0
(gdb) q

After the patch:

(gdb) b main
Breakpoint 1 at 0x40032a: file noshlib.c, line 11.
(gdb) b foo
Breakpoint 2 at 0x400310: file noshlib.c, line 6.
(gdb) r

Breakpoint 1, main () at noshlib.c:11
11          return foo();
(gdb) c

Breakpoint 2, foo () at noshlib.c:6
6           return a_global + a_local + a_static;
(gdb) display a_global
(gdb) display a_local
(gdb) display a_static
(gdb) r

Breakpoint 1, main () at noshlib.c:11
11          return foo();
warning: Unable to display "a_static": No symbol "a_static" in current context.
warning: Unable to display "a_local": No symbol "a_local" in current context.
1: a_global = 0
(gdb) c

Breakpoint 2, foo () at noshlib.c:6
6           return a_global + a_local + a_static;
1: a_global = 0


I've updated the patch to only clear displays which actually are
about to become dangling, and extended the test to check that displays
that refer to the main executable are not affected.

Thanks,
-- 
Paul Pluzhnikov

Attachment: gdb-display-crash-20090218.txt
Description: Text document


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