public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line
@ 2005-11-18 18:08 barbieri at gmail dot com
2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-11-18 18:08 UTC (permalink / raw)
To: gcc-bugs
I'm writing a tutorial on a HelloWorld compiler front-end for GCC
(http://svn.gna.org/viewcvs/gsc/branches/hello-world/doc/hello.xml) and noticed
that a function with statements but no DECL_SOURCE_FILE set, seg-faults on
cgraph_finalize_function(), because it calls
gimple-low.c:lower_function_body(), which in turn does:
SET_EXPR_LOCATION (x, cfun->function_end_locus);
however, if cfun->function_end_locus is empty ({NULL, 0}), it will call
tree.c:annotate_with_file_line() with file=NULL, and it will fail on this "if":
if (last_annotated_node
&& last_annotated_node->line == line
&& (last_annotated_node->file == file
|| !strcmp (last_annotated_node->file, file)))
because strcmp (last_annotated_node->file, file), with file=NULL will
seg-fault.
The attached patch checks if file is NULL before using strcmp.
The program that fails build is:
http://svn.gna.org/viewcvs/gsc/branches/hello-world/compiler/hello1.c?rev=551
--
Summary: GCC segfault's on strcmp in
tree.c:annotate_with_file_line
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: barbieri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
@ 2005-11-18 18:09 ` barbieri at gmail dot com
2005-11-18 18:17 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-11-18 18:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from barbieri at gmail dot com 2005-11-18 18:09 -------
Created an attachment (id=10274)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10274&action=view)
gcc-annotate_with_file_line.patch
Fix segfault
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
@ 2005-11-18 18:17 ` pinskia at gcc dot gnu dot org
2005-11-18 18:36 ` barbieri at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-18 18:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-18 18:17 -------
Actually this should never happen in general. Your front-end really should be
adding locus on the statements.
I will let someone else decide if this is a real middle-end bug or a bug in
your front-end.
I should note that I don't like the check in annotate_with_file_line at all. I
would rather have a check in gimple-low.c instead.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
2005-11-18 18:17 ` pinskia at gcc dot gnu dot org
@ 2005-11-18 18:36 ` barbieri at gmail dot com
2005-12-07 10:49 ` barbieri at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-11-18 18:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from barbieri at gmail dot com 2005-11-18 18:36 -------
Created an attachment (id=10276)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10276&action=view)
gcc-lower_function_body.patch
Alternative patch that also fix seg fault, but earlier.
It's uglier than the previous, and is more restricted, since it just protect
the behaviour from gimple-low.c:lower_function_body(), while the previous patch
does the check for every use of annotate_with_file_line, used by
SET_EXPR_LOCATION.
I cannot know if this is a bug in the middle-end, since there is no
documentation on when I need to set this value. If so, probably we can use
gcc_assert() to confirm this?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
` (2 preceding siblings ...)
2005-11-18 18:36 ` barbieri at gmail dot com
@ 2005-12-07 10:49 ` barbieri at gmail dot com
2005-12-24 22:47 ` barbieri at gmail dot com
2009-02-22 16:36 ` steven at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-12-07 10:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from barbieri at gmail dot com 2005-12-07 10:49 -------
So, this is a bug.
I just need a confirmation if it's a bug in the middle-end layer, so there is
already a patch, or if this is a bug in the front-end, then I will add the
check to the gimplify code.
Since there is no documentation on the expected behaviour, we need to be safe.
Also, it would be good to have this before our presentation at LinuxConf.AU,
then we can be sure what's expected and how to teach others.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
` (3 preceding siblings ...)
2005-12-07 10:49 ` barbieri at gmail dot com
@ 2005-12-24 22:47 ` barbieri at gmail dot com
2009-02-22 16:36 ` steven at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-12-24 22:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from barbieri at gmail dot com 2005-12-24 22:47 -------
any news on this front?
I'll present a tutorial in LinuxConf.au and need to know if front-end should
provide the information or middle-end should handle it.
In both cases I'll provide the patch to gcc, but I need to know where the bug
is.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/24932] GCC segfault's on strcmp in tree.c:annotate_with_file_line
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
` (4 preceding siblings ...)
2005-12-24 22:47 ` barbieri at gmail dot com
@ 2009-02-22 16:36 ` steven at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-02-22 16:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from steven at gcc dot gnu dot org 2009-02-22 16:36 -------
Locations are now handled differently (mapped locations).
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-02-22 16:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
2005-11-18 18:17 ` pinskia at gcc dot gnu dot org
2005-11-18 18:36 ` barbieri at gmail dot com
2005-12-07 10:49 ` barbieri at gmail dot com
2005-12-24 22:47 ` barbieri at gmail dot com
2009-02-22 16:36 ` steven at gcc dot gnu dot org
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).