Bug 11098 - GDB/MI crashes in -var-update when using pretty-printing
Summary: GDB/MI crashes in -var-update when using pretty-printing
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: mi (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 7.1
Assignee: Tom Tromey
URL:
Keywords:
: 11081 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-12-16 18:16 UTC by Oliver Gerlich
Modified: 2010-03-03 19:03 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2010-03-03 17:20:10


Attachments
testapp1.C source code (643 bytes, text/x-c++src)
2009-12-16 18:20 UTC, Oliver Gerlich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Gerlich 2009-12-16 18:16:02 UTC
In gdb -i mi, when creating a variable object, then switching to another frame, and then updating the 
variable, GDB crashes. These are the exact steps leading to the crash:

$ gdb -i mi
2-enable-pretty-printing
3-interpreter-exec console "python import sys; from libstdcxx.v6.printers import 
register_libstdcxx_printers; register_libstdcxx_printers (None)" 
4-file-exec-and-symbols ./testapp1
5-interpreter-exec console "b testapp1.C:26"
8-exec-run
[wait until breakpoint is hit]
12-stack-select-frame 2
14-var-create - @ allResults
16-stack-select-frame 1
17-var-update --all-values "var1"

The testapp1 source code is attached below (build with "g++ -g -O0 -o testapp1 testapp1.C"; I used 
g++ 4.3.3 on Ubuntu 9.04).
allResults is a local variable that exists in frame 2 but not in frame 1.
If pretty-printing is not enabled, the crash does not occur. Similarly, when looking at a global variable  
instead (like someGlobalVar), the crash doesn't occur.

Here is the backtrace from gdb crash:
(gdb) bt
#0  0xb7c3c07a in strcmp () from /lib/tls/i686/cmov/libc.so.6
#1  0x08201972 in install_new_value (var=0x8ac6608, value=0x0, initial=0) at varobj.c:1586
#2  0x08201d28 in varobj_update (varp=0xbf94f0b0, explicit=1) at varobj.c:1713
#3  0x080fb023 in varobj_update_one (var=0x8ac6608, print_values=PRINT_ALL_VALUES, explicit=1) 
at ./mi/mi-cmd-var.c:721
#4  0x080faff7 in mi_cmd_var_update (command=0x8abc828 "var-update", argv=0x8950380, 
argc=2) at ./mi/mi-cmd-var.c:703
#5  0x080ffffd in mi_cmd_execute (parse=0x89f9108) at ./mi/mi-main.c:1388
#6  0x080ff972 in captured_mi_execute_command (uiout=0x89895f0, data=0x89f9108) at ./mi/mi-
main.c:1194
#7  0x081832e2 in catch_exception (uiout=0x89895f0, func=0x80ff8ae 
<captured_mi_execute_command>, func_args=0x89f9108, mask=6) at exceptions.c:462
#8  0x080ffbef in mi_execute_command (cmd=0x8bc8290 "17-var-update --all-values \"var1\"", 
from_tty=1) at ./mi/mi-main.c:1288
#9  0x080fd0bc in mi_execute_command_wrapper (cmd=0x8bc8290 "17-var-update --all-values 
\"var1\"") at ./mi/mi-interp.c:251
#10 0x0818aa81 in gdb_readline2 (client_data=0x0) at event-top.c:817
#11 0x0818a1a6 in stdin_event_handler (error=0, client_data=0x0) at event-top.c:433
#12 0x08188e86 in handle_file_event (data=...) at event-loop.c:812
#13 0x081885cb in process_event () at event-loop.c:394
#14 0x081886a3 in gdb_do_one_event (data=0x0) at event-loop.c:459
#15 0x081834ab in catch_errors (func=0x81885e0 <gdb_do_one_event>, func_args=0x0, 
errstring=0x8365150 "", mask=6) at exceptions.c:510
#16 0x081886e6 in start_event_loop () at event-loop.c:483
#17 0x080fd131 in mi_command_loop (mi_version=2) at ./mi/mi-interp.c:281
#18 0x080fd0e4 in mi2_command_loop () at ./mi/mi-interp.c:263
#19 0x08183a4c in current_interp_command_loop () at interps.c:288
#20 0x0808e950 in captured_command_loop (data=0x0) at ./main.c:226
#21 0x081834ab in catch_errors (func=0x808e945 <captured_command_loop>, func_args=0x0, 
errstring=0x832441f "", mask=6) at exceptions.c:510
#22 0x0808f898 in captured_main (data=0xbf94f4f0) at ./main.c:902
#23 0x081834ab in catch_errors (func=0x808e986 <captured_main>, func_args=0xbf94f4f0, 
errstring=0x832441f "", mask=6) at exceptions.c:510
#24 0x0808f8ce in gdb_main (args=0xbf94f4f0) at ./main.c:911
#25 0x0808e6c7 in main (argc=3, argv=0xbf94f5a4) at gdb.c:33

The problem is reproducable for me.
Any hints at workarounds for GDB 7.0 would be highly appreciated :-)
Comment 1 Oliver Gerlich 2009-12-16 18:20:07 UTC
Created attachment 4475 [details]
testapp1.C source code
Comment 2 Vladimir Prus 2009-12-31 18:51:09 UTC
I could not reproduce this either with CVS HEAD or GDB 7.0 branch.

Could you try with CVS HEAD and see if that's fixed there. In any case, it's
unlikely that any workaround for such a bug would exist.
Comment 3 Tom Tromey 2010-03-03 17:11:42 UTC
I reproduced it with head today, on F11.
I had to modify the input script a tiny bit to get it to find
my libstdc++ printers.
Comment 4 Tom Tromey 2010-03-03 17:20:10 UTC
Testing a patch.
Comment 5 Sourceware Commits 2010-03-03 18:33:00 UTC
Subject: Bug 11098

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-03-03 18:32:44

Modified files:
	gdb            : ChangeLog varobj.c 

Log message:
	PR mi/11098:
	* varobj.c (install_new_value): Handle case where new print_value
	is NULL.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11418&r2=1.11419
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/varobj.c.diff?cvsroot=src&r1=1.155&r2=1.156

Comment 6 Sourceware Commits 2010-03-03 18:33:17 UTC
Subject: Bug 11098

CVSROOT:	/cvs/src
Module name:	src
Branch: 	gdb_7_1-branch
Changes by:	tromey@sourceware.org	2010-03-03 18:33:04

Modified files:
	gdb            : ChangeLog varobj.c 

Log message:
	PR mi/11098:
	* varobj.c (install_new_value): Handle case where new print_value
	is NULL.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.11378.2.15&r2=1.11378.2.16
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/varobj.c.diff?cvsroot=src&only_with_tag=gdb_7_1-branch&r1=1.154.2.1&r2=1.154.2.2

Comment 7 Tom Tromey 2010-03-03 18:33:40 UTC
Fix checked in.
Comment 8 Tom Tromey 2010-03-03 19:03:35 UTC
*** Bug 11081 has been marked as a duplicate of this bug. ***