This is the mail archive of the gdb-prs@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]

[Bug breakpoints/15433] New: GDB crashes when using agent dprintf, %s format, and an in-line string


http://sourceware.org/bugzilla/show_bug.cgi?id=15433

             Bug #: 15433
           Summary: GDB crashes when using agent dprintf, %s format, and
                    an in-line string
           Product: gdb
           Version: 7.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: marc.khouzam@ericsson.com
    Classification: Unclassified


If I use the agent dprintf and use a %s in the dprintf string, and use an
in-line string, GDB crashes (apparently when it reaches the dprintf).  The
dprintf format is something like
  dprintf 8,"s is %s\n","hello"

This happens in both GDB 7.5 and 7.6.  It is kind of a corner case, but the
Eclipse support for dprintf happens to hit it often.  This is because I want to
use this in-line string format as a default dprintf string in Eclipse; the idea
is to show the user that the % format is supported.  So by default, I wanted
eclipse to use
  dprintf myFile:100,"hit line %d of file %s\n",100,"myFile"

Session followed by backtrace:

GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file /home/lmckhou/loopfirst
Reading symbols from /home/lmckhou/loopfirst...done.
(gdb) l
1       #include <unistd.h>
2       #include <stdio.h>
3
4       int main() {
5           int max = 90;
6           for (int i=0;i<max;i++) {
7               printf("i is %d\n",i);
8               sleep(1);
9           }
10          return 0;
(gdb) l
11      }
(gdb) target extended-remote :9999
Remote debugging using :9999
(gdb) set remote exec-file /home/lmckhou/loopfirst
(gdb) set dprintf-style agent
(gdb) dprintf 8,"%s","hello"
Dprintf 1 at 0x400570: file loopfirst.cc, line 8.
(gdb) info b
Num     Type           Disp Enb Address            What
1       dprintf        keep y   0x0000000000400570 in main() at loopfirst.cc:8
        agent-printf "%s","hello"
(gdb) r
Starting program: /home/lmckhou/loopfirst 

Program received signal SIGSEGV, Segmentation fault.
0x000000000049d753 in sprintf (__fmt=0x74cc2f "X%x,", __s=0xd567b3 "") at
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34
34        return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
(gdb) bt
#0  0x000000000049d753 in sprintf (__fmt=0x74cc2f "X%x,", __s=0xd567b3 "") at
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34
#1  remote_add_target_side_commands (bp_tgt=0xd2ddf0, buf=<optimized out>,
gdbarch=<optimized out>) at ../../gdb/remote.c:8054
#2  0x00000000004a7b33 in remote_add_target_side_commands (buf=0xd567a9
",1;cmds:1,", bp_tgt=0xd2ddf0, gdbarch=<optimized out>)
    at ../../gdb/remote.c:8040
#3  remote_insert_breakpoint (gdbarch=0xd0bba0, bp_tgt=0xd2ddf0) at
../../gdb/remote.c:8102
#4  0x000000000051e268 in insert_bp_location (bl=0xd2dd60,
tmp_error_stream=0xd36020, disabled_breaks=0x7fffffffde74, 
    hw_breakpoint_error=0x7fffffffde78,
hw_bp_error_explained_already=0x7fffffffde7c) at ../../gdb/breakpoint.c:2498
#5  0x000000000051edf6 in insert_breakpoint_locations () at
../../gdb/breakpoint.c:2873
#6  0x000000000057f155 in proceed (addr=<optimized out>, siggnal=GDB_SIGNAL_0,
step=0) at ../../gdb/infrun.c:2243
#7  0x0000000000572d54 in run_command_1 (args=0x0, from_tty=1,
tbreak_at_main=<optimized out>) at ../../gdb/infcmd.c:617
#8  0x000000000064a60a in execute_command (p=0xb67161 "", from_tty=1) at
../../gdb/top.c:484
#9  0x00000000005933b5 in command_handler (command=0xb67160 "") at
../../gdb/event-top.c:431
#10 0x0000000000593dcb in command_line_handler (rl=<optimized out>) at
../../gdb/event-top.c:629
#11 0x00000000006907b9 in rl_callback_read_char () at
../../readline/callback.c:220
#12 0x0000000000593429 in rl_callback_read_char_wrapper (client_data=<optimized
out>) at ../../gdb/event-top.c:163
#13 0x00000000005925e4 in process_event () at ../../gdb/event-loop.c:342
#14 process_event () at ../../gdb/event-loop.c:314
#15 0x00000000005929b8 in gdb_do_one_event () at ../../gdb/event-loop.c:406
#16 0x0000000000592b55 in start_event_loop () at ../../gdb/event-loop.c:431
#17 0x000000000058c033 in captured_command_loop (data=<optimized out>) at
../../gdb/main.c:258
#18 0x000000000058abeb in catch_errors (func=0x58c020 <captured_command_loop>,
func_args=0x0, errstring=0x74c8cd "", mask=6)
    at ../../gdb/exceptions.c:546
#19 0x000000000058c9c6 in captured_main (data=<optimized out>) at
../../gdb/main.c:1041
#20 0x000000000058abeb in catch_errors (func=0x58c330 <captured_main>,
func_args=0x7fffffffe350, errstring=0x74c8cd "", mask=6)
    at ../../gdb/exceptions.c:546
#21 0x000000000058d354 in gdb_main (args=<optimized out>) at
../../gdb/main.c:1050
#22 0x00000000004595de in main (argc=<optimized out>, argv=<optimized out>) at
../../gdb/gdb.c:34

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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