From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92699 invoked by alias); 18 Mar 2015 19:29:48 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 92674 invoked by uid 48); 18 Mar 2015 19:29:48 -0000 From: "aldyh at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/18142] New: dprintf to stderr with no stderr DIE will segfault Date: Wed, 18 Mar 2015 19:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-q1/txt/msg00461.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18142 Bug ID: 18142 Summary: dprintf to stderr with no stderr DIE will segfault Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: aldyh at redhat dot com I have a faulty gcc which is failing to generate a DIE for stderr in this sample: struct _IO_FILE; extern struct _IO_FILE *stderr; extern int fprintf (struct _IO_FILE *__restrict __stream, const char *__restrict __format, ...); int main () { fprintf (stderr, "also to stderr\n"); int local = 8; return local; } When using dprintf to stderr, gdb will segfault. Since I can print "stderr" from the gdb command line, presumably gdb is using its internal stderr (which is an int not a FILE *), and dying. Perhaps this is a case of the user being stupid, but it seems like gdb should be able to figure out that dprintf should not use the builtin stderr, which AFAICT, is just complete garbage. Feel free to ignore this :). I'm not that attached to this bug, and I'm fixing gcc anyhow :). (gdb) b main Breakpoint 1 at 0x40055e: file x.i, line 8. (gdb) r Starting program: /home/build/dearly/gcc/bad.out Breakpoint 1, main () at x.i:8 8 fprintf (stderr, "also to stderr\n"); (gdb) p stderr $1 = -136485120 (gdb) dprintf 10,"At foo entry\n" Dprintf 2 at 0x400583: file x.i, line 10. (gdb) set dprintf-style call (gdb) set dprintf-function fprintf (gdb) set dprintf-channel stderr (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/build/dearly/gcc/bad.out Breakpoint 1, main () at x.i:8 8 fprintf (stderr, "also to stderr\n"); (gdb) print stderr $2 = -136485120 (gdb) c Continuing. also to stderr Program received signal SIGSEGV, Segmentation fault. -- You are receiving this mail because: You are on the CC list for the bug.