public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
@ 2022-06-29  4:57 zsojka at seznam dot cz
  2022-06-30 14:25 ` [Bug middle-end/106133] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zsojka at seznam dot cz @ 2022-06-29  4:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106133
           Summary: ICE: SIGSEGV in
                    diagnostic_output_format_init_json_file() with
                    -fdiagnostics-format=json-file -E
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Compiler output:
$ echo -n > empty.c
$ x86_64-pc-linux-gnu-gcc -fdiagnostics-format=json-file -E empty.c -wrapper
valgrind,-q
==20305== Invalid read of size 1
==20305==    at 0x4846FA2: strlen (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==20305==    by 0x2634511: xstrdup (xstrdup.c:33)
==20305==    by 0x25A92C8:
diagnostic_output_format_init_json_file(diagnostic_context*, char const*)
(diagnostic-format-json.cc:375)
==20305==    by 0x258BF28: common_handle_option(gcc_options*, gcc_options*,
cl_decoded_option const*, unsigned int, int, unsigned int, cl_option_handlers
const*, diagnostic_context*, void (*)()) (opts.cc:2853)
==20305==    by 0x2590F38: handle_option(gcc_options*, gcc_options*,
cl_decoded_option const*, unsigned int, int, unsigned int, cl_option_handlers
const*, bool, diagnostic_context*) (opts-common.cc:1246)
==20305==    by 0x259106E: read_cmdline_option(gcc_options*, gcc_options*,
cl_decoded_option*, unsigned int, unsigned int, cl_option_handlers const*,
diagnostic_context*) (opts-common.cc:1574)
==20305==    by 0x129BC64: read_cmdline_options (opts-global.cc:239)
==20305==    by 0x129BC64: decode_options(gcc_options*, gcc_options*,
cl_decoded_option*, unsigned int, unsigned int, diagnostic_context*, void
(*)()) (opts-global.cc:321)
==20305==    by 0xD114AD: toplev::main(int, char**) (toplev.cc:2265)
==20305==    by 0xD13A6A: main (main.cc:39)
==20305==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==20305== 
0x13a859f crash_signal
        /repo/gcc-trunk/gcc/toplev.cc:322
0x2634511 xstrdup
        /repo/gcc-trunk/libiberty/xstrdup.c:33
0x25a92c8 diagnostic_output_format_init_json_file(diagnostic_context*, char
const*)
        /repo/gcc-trunk/gcc/diagnostic-format-json.cc:375
0x258bf28 common_handle_option(gcc_options*, gcc_options*, cl_decoded_option
const*, unsigned int, int, unsigned int, cl_option_handlers const*,
diagnostic_context*, void (*)())
        /repo/gcc-trunk/gcc/opts.cc:2853
0x2590f38 handle_option
        /repo/gcc-trunk/gcc/opts-common.cc:1246
0x259106e read_cmdline_option(gcc_options*, gcc_options*, cl_decoded_option*,
unsigned int, unsigned int, cl_option_handlers const*, diagnostic_context*)
        /repo/gcc-trunk/gcc/opts-common.cc:1574
0x129bc64 read_cmdline_options
        /repo/gcc-trunk/gcc/opts-global.cc:239
0x129bc64 decode_options(gcc_options*, gcc_options*, cl_decoded_option*,
unsigned int, unsigned int, diagnostic_context*, void (*)())
        /repo/gcc-trunk/gcc/opts-global.cc:321
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r13-1327-20220628144301-g243b5396106-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r13-1327-20220628144301-g243b5396106-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220628 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
@ 2022-06-30 14:25 ` marxin at gcc dot gnu.org
  2022-06-30 14:25 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-30 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |dmalcolm at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-06-30

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
With -E the base_file_name == NULL. What about the following patch:

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 22f7b0b6d6e..5d0137fd974 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -2246,6 +2246,9 @@ diagnostic_output_format_init (diagnostic_context
*context,
                               const char *base_file_name,
                               enum diagnostics_output_format format)
 {
+  if (base_file_name == NULL)
+    return;
+
   switch (format)
     {
     default:

David, what do you think?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
  2022-06-30 14:25 ` [Bug middle-end/106133] " marxin at gcc dot gnu.org
@ 2022-06-30 14:25 ` marxin at gcc dot gnu.org
  2023-01-06 10:22 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-30 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
  2022-06-30 14:25 ` [Bug middle-end/106133] " marxin at gcc dot gnu.org
  2022-06-30 14:25 ` marxin at gcc dot gnu.org
@ 2023-01-06 10:22 ` marxin at gcc dot gnu.org
  2023-01-06 11:24 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-06 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Lemme send the patch to gcc-patches ML.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-01-06 10:22 ` marxin at gcc dot gnu.org
@ 2023-01-06 11:24 ` marxin at gcc dot gnu.org
  2023-01-10 13:31 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-06 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
*** Bug 108307 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2023-01-06 11:24 ` marxin at gcc dot gnu.org
@ 2023-01-10 13:31 ` marxin at gcc dot gnu.org
  2023-03-16 14:04 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-10 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Btw. it crashes also for:

gcc empty.c -fdiagnostics-format=sarif-file --save-temps -c
0xf02ebf crash_signal
        /home/marxin/Programming/gcc/gcc/toplev.cc:314
0x7ffff78b78df ???
       
/usr/src/debug/glibc-2.36/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7ffff79e1cfd __strlen_avx2
        ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
0x1fdbb61 xstrdup
        /home/marxin/Programming/gcc/libiberty/xstrdup.c:33
0x1f4be5b diagnostic_output_format_init_sarif_file(diagnostic_context*, char
const*)
        /home/marxin/Programming/gcc/gcc/diagnostic-format-sarif.cc:1585
0x1f2b395 common_handle_option(gcc_options*, gcc_options*, cl_decoded_option
const*, unsigned int, int, unsigned int, cl_option_handlers const*,
diagnostic_context*, void (*)())
        /home/marxin/Programming/gcc/gcc/opts.cc:2866
0x1f2ff08 handle_option
        /home/marxin/Programming/gcc/gcc/opts-common.cc:1248
0x1f3003e read_cmdline_option(gcc_options*, gcc_options*, cl_decoded_option*,
unsigned int, unsigned int, cl_option_handlers const*, diagnostic_context*)
        /home/marxin/Programming/gcc/gcc/opts-common.cc:1578
0xe148e4 read_cmdline_options
        /home/marxin/Programming/gcc/gcc/opts-global.cc:239
0xe148e4 decode_options(gcc_options*, gcc_options*, cl_decoded_option*,
unsigned int, unsigned int, diagnostic_context*, void (*)())
        /home/marxin/Programming/gcc/gcc/opts-global.cc:321
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2023-01-10 13:31 ` marxin at gcc dot gnu.org
@ 2023-03-16 14:04 ` marxin at gcc dot gnu.org
  2023-03-16 14:50 ` cvs-commit at gcc dot gnu.org
  2023-03-16 14:51 ` marxin at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-03-16 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|marxin at gcc dot gnu.org          |unassigned at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
I've been waiting for a review for quite some time:
https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614059.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2023-03-16 14:04 ` marxin at gcc dot gnu.org
@ 2023-03-16 14:50 ` cvs-commit at gcc dot gnu.org
  2023-03-16 14:51 ` marxin at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-16 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:c5e2c3dd6afcf9b152df72b30e205b0180c0afd5

commit r13-6713-gc5e2c3dd6afcf9b152df72b30e205b0180c0afd5
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jan 10 15:14:05 2023 +0100

    middle-end: always find a basename for -fdiagnostics-format=*

    In some situations, x_dump_base_name is NULL and thus we can
    and should use x_main_input_basename which should never be NULL.

            PR middle-end/106133

    gcc/ChangeLog:

            * gcc.cc (driver_handle_option): Use x_main_input_basename
            if x_dump_base_name is null.
            * opts.cc (common_handle_option): Likewise.

    gcc/testsuite/ChangeLog:

            * c-c++-common/pr106133.c: New test.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/106133] ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E
  2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2023-03-16 14:50 ` cvs-commit at gcc dot gnu.org
@ 2023-03-16 14:51 ` marxin at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-03-16 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-16 14:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29  4:57 [Bug c/106133] New: ICE: SIGSEGV in diagnostic_output_format_init_json_file() with -fdiagnostics-format=json-file -E zsojka at seznam dot cz
2022-06-30 14:25 ` [Bug middle-end/106133] " marxin at gcc dot gnu.org
2022-06-30 14:25 ` marxin at gcc dot gnu.org
2023-01-06 10:22 ` marxin at gcc dot gnu.org
2023-01-06 11:24 ` marxin at gcc dot gnu.org
2023-01-10 13:31 ` marxin at gcc dot gnu.org
2023-03-16 14:04 ` marxin at gcc dot gnu.org
2023-03-16 14:50 ` cvs-commit at gcc dot gnu.org
2023-03-16 14:51 ` marxin at gcc dot gnu.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).