public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/18142] New: dprintf to stderr with no stderr DIE will segfault
@ 2015-03-18 19:36 aldyh at redhat dot com
2015-03-18 20:55 ` [Bug gdb/18142] " aldyh at redhat dot com
0 siblings, 1 reply; 2+ messages in thread
From: aldyh at redhat dot com @ 2015-03-18 19:36 UTC (permalink / raw)
To: gdb-prs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug gdb/18142] dprintf to stderr with no stderr DIE will segfault
2015-03-18 19:36 [Bug gdb/18142] New: dprintf to stderr with no stderr DIE will segfault aldyh at redhat dot com
@ 2015-03-18 20:55 ` aldyh at redhat dot com
0 siblings, 0 replies; 2+ messages in thread
From: aldyh at redhat dot com @ 2015-03-18 20:55 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18142
--- Comment #1 from aldyh at redhat dot com ---
Created attachment 8196
--> https://sourceware.org/bugzilla/attachment.cgi?id=8196&action=edit
faulty assembly with no DIE for stderr
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-18 19:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 19:36 [Bug gdb/18142] New: dprintf to stderr with no stderr DIE will segfault aldyh at redhat dot com
2015-03-18 20:55 ` [Bug gdb/18142] " aldyh at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).