public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ro at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug modula2/101392] cc1gm2 -fdump-system-exports SEGV on Solaris/SPARC
Date: Tue, 14 Sep 2021 10:15:19 +0000	[thread overview]
Message-ID: <bug-101392-4-96r7Dh4ZlP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101392-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101392

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-09-14
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Rainer Orth <ro at gcc dot gnu.org> ---
(In reply to Rainer Orth from comment #0)

> I couldn't make much sense of this yet.  Probably requires rebuilding cc1gm2
> with
> -g3 -O0.

I've now done just that.  Here's what I find:

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfeb51bb0 in strlen () from /lib/libc.so.1
(gdb) where
#0  0xfeb51bb0 in strlen () from /lib/libc.so.1
#1  0xfeb937fc in strdup () from /lib/libc.so.1
#2  0x02a48c90 in lrealpath (filename=0x0)
    at /vol/gcc/src/git/modula-2/libiberty/lrealpath.c:88
#3  0x02a45fa4 in canonical_filename_eq (a=0xffbff8e2 "SYSTEM.s", b=0x0)
    at /vol/gcc/src/git/modula-2/libiberty/filename_cmp.c:216
#4  0x016e97c8 in init_asm_output (name=0x0)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:714
#5  0x016ed1dc in lang_dependent_init (name=0x0)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:1927
#6  0x016edf58 in do_compile () at /vol/gcc/src/git/modula-2/gcc/toplev.c:2218
#7  0x016ee4a8 in toplev::main (this=0xffbff6e2, argc=7, argv=0xffbff74c)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:2372
#8  0x02924ec4 in main (argc=7, argv=0xffbff74c)
    at /vol/gcc/src/git/modula-2/gcc/main.c:39

#4  0x016e97c8 in init_asm_output (name=0x0)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:714
714           else if (!canonical_filename_eq (asm_file_name, name)
(gdb) p asm_file_name
$3 = 0xffbff8e2 "SYSTEM.s"
(gdb) p name
$4 = 0x0
(gdb) up
#5  0x016ed1dc in lang_dependent_init (name=0x0)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:1927
1927          init_asm_output (name);
gdb) up
#6  0x016edf58 in do_compile () at /vol/gcc/src/git/modula-2/gcc/toplev.c:2218
2218          if (lang_dependent_init (main_input_filename))
(gdb) p main_input_filename
$6 = 0x0
(gdb) up
#7  0x016ee4a8 in toplev::main (this=0xffbff6e2, argc=7, argv=0xffbff74c)
    at /vol/gcc/src/git/modula-2/gcc/toplev.c:2372
2372          do_compile ();

Ultimately, the problem is two-fold:

* cc1gm2 doesn't set main_input_filename (perhaps only with
-fdump-system-exports,
  I haven't checked)
* In the end, libiberty's lrealpath is called with lrealpath (NULL, NULL)
  which again calls strdup (NULL), leading to the SEGV.  I couldn't find a
  clear indication if this is supported by the C standard, but even if I harden
  lrealpath to avoid strdup(NULL), I get more SEGVs later on in other places.

So clearly the error is not setting main_input_filename.  No idea why this
happens
for gm2 only or how to fix this, though.

  reply	other threads:[~2021-09-14 10:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 12:34 [Bug modula2/101392] New: " ro at gcc dot gnu.org
2021-09-14 10:15 ` ro at gcc dot gnu.org [this message]
2022-05-03 15:27 ` [Bug modula2/101392] " gaius at gcc dot gnu.org
2022-05-04 13:18 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-07 13:15 ` ro at gcc dot gnu.org
2022-11-09 16:30 ` gaius at gcc dot gnu.org
2022-11-10 13:01 ` ro at CeBiTec dot Uni-Bielefeld.DE
2022-11-11 10:50 ` gaius at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101392-4-96r7Dh4ZlP@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).