public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
@ 2023-10-05  5:27 zsojka at seznam dot cz
  2023-10-06 13:59 ` [Bug driver/111700] " dmalcolm at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2023-10-05  5:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111700
           Summary: ICE: SIGSEGV in needs_read_p (input.cc:598) with
                    -fdiagnostics-format=sarif-file or
                    -fdiagnostics-format=sarif-stderr on pre-processed
                    input
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: diagnostic, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Compiler output:

$ cat tmp.i
# 0 ""
x;

$ x86_64-pc-linux-gnu-gcc -fdiagnostics-format=sarif-stderr tmp.i -wrapper
valgrind,-q
==21217== Invalid read of size 8
==21217==    at 0x289B3E4: needs_read_p (input.cc:598)
==21217==    by 0x289B3E4: maybe_read_data (input.cc:665)
==21217==    by 0x289B3E4: file_cache_slot::get_next_line(char**, long*)
(input.cc:715)
==21217==    by 0x289C6BF: get_full_file_content (input.cc:471)
==21217==    by 0x289C6BF: file_cache::get_source_file_content(char const*)
(input.cc:1075)
==21217==    by 0x2877B83:
sarif_builder::maybe_make_artifact_content_object(char const*) const
(diagnostic-format-sarif.cc:1545)
==21217==    by 0x2877D1F: sarif_builder::make_artifact_object(char const*)
(diagnostic-format-sarif.cc:1524)
==21217==    by 0x2879FF7: sarif_builder::make_run_object(sarif_invocation*,
json::array*) (diagnostic-format-sarif.cc:1340)
==21217==    by 0x287A22E:
sarif_builder::make_top_level_object(sarif_invocation*, json::array*)
(diagnostic-format-sarif.cc:1296)
==21217==    by 0x287A285: sarif_builder::flush_to_file(_IO_FILE*)
(diagnostic-format-sarif.cc:473)
==21217==    by 0x287C200: ~sarif_stream_output_format
(diagnostic-format-sarif.cc:1749)
==21217==    by 0x287C200:
sarif_stream_output_format::~sarif_stream_output_format()
(diagnostic-format-sarif.cc:1750)
==21217==    by 0x286E861: diagnostic_finish(diagnostic_context*)
(diagnostic.cc:304)
==21217==    by 0xDBAA7F: toplev::main(int, char**) (toplev.cc:2310)
==21217==    by 0xDBCA7A: main (main.cc:39)
==21217==  Address 0x10 is not stack'd, malloc'd or (recently) free'd


$ x86_64-pc-linux-gnu-gcc -fdiagnostics-format=sarif-file tmp.i -wrapper
valgrind,-q
==32755== Invalid read of size 8
==32755==    at 0x289B3E4: needs_read_p (input.cc:598)
==32755==    by 0x289B3E4: maybe_read_data (input.cc:665)
==32755==    by 0x289B3E4: file_cache_slot::get_next_line(char**, long*)
(input.cc:715)
==32755==    by 0x289C6BF: get_full_file_content (input.cc:471)
==32755==    by 0x289C6BF: file_cache::get_source_file_content(char const*)
(input.cc:1075)
==32755==    by 0x2877B83:
sarif_builder::maybe_make_artifact_content_object(char const*) const
(diagnostic-format-sarif.cc:1545)
==32755==    by 0x2877D1F: sarif_builder::make_artifact_object(char const*)
(diagnostic-format-sarif.cc:1524)
==32755==    by 0x2879FF7: sarif_builder::make_run_object(sarif_invocation*,
json::array*) (diagnostic-format-sarif.cc:1340)
==32755==    by 0x287A22E:
sarif_builder::make_top_level_object(sarif_invocation*, json::array*)
(diagnostic-format-sarif.cc:1296)
==32755==    by 0x287A285: sarif_builder::flush_to_file(_IO_FILE*)
(diagnostic-format-sarif.cc:473)
==32755==    by 0x287BE31:
sarif_file_output_format::~sarif_file_output_format()
(diagnostic-format-sarif.cc:1778)
==32755==    by 0x287C018:
sarif_file_output_format::~sarif_file_output_format()
(diagnostic-format-sarif.cc:1781)
==32755==    by 0x286E861: diagnostic_finish(diagnostic_context*)
(diagnostic.cc:304)
==32755==    by 0xDBAA7F: toplev::main(int, char**) (toplev.cc:2310)
==32755==    by 0xDBCA7A: main (main.cc:39)
==32755==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==32755== 
error: unable to open '' for writing: No such file or directory
Internal compiler error:
0x14a9ccf crash_signal
        /repo/gcc-trunk/gcc/toplev.cc:314
...

$ 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-20231003001722-g41d1c9a9795-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.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-20231003001722-g41d1c9a9795-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20231003 (experimental) (GCC)

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

* [Bug driver/111700] ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
  2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
@ 2023-10-06 13:59 ` dmalcolm at gcc dot gnu.org
  2023-10-08 22:50 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-10-06 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-06
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug.

Confirmed with trunk and gcc 13:
  trunk: https://godbolt.org/z/7cb1Ed83r
  13.2: https://godbolt.org/z/GzYfMnbss

I'm working on a fix.

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

* [Bug driver/111700] ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
  2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
  2023-10-06 13:59 ` [Bug driver/111700] " dmalcolm at gcc dot gnu.org
@ 2023-10-08 22:50 ` cvs-commit at gcc dot gnu.org
  2023-10-08 23:07 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-08 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:94caa6a6b4bd73b6c2bf3ab5e43ca42c5da4287a

commit r14-4474-g94caa6a6b4bd73b6c2bf3ab5e43ca42c5da4287a
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Sun Oct 8 18:43:15 2023 -0400

    diagnostics: fix ICE on sarif output when source file is unreadable
[PR111700]

    gcc/ChangeLog:
            PR driver/111700
            * input.cc (file_cache::add_file): Update leading comment to
            clarify that it can fail.
            (file_cache::lookup_or_add_file): Likewise.
            (file_cache::get_source_file_content): Gracefully handle
            lookup_or_add_file failing.

    gcc/testsuite/ChangeLog:
            PR driver/111700
            * c-c++-common/diagnostic-format-sarif-file-pr111700.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug driver/111700] ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
  2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
  2023-10-06 13:59 ` [Bug driver/111700] " dmalcolm at gcc dot gnu.org
  2023-10-08 22:50 ` cvs-commit at gcc dot gnu.org
@ 2023-10-08 23:07 ` dmalcolm at gcc dot gnu.org
  2024-05-09 17:12 ` cvs-commit at gcc dot gnu.org
  2024-05-10 18:54 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-10-08 23:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed on trunk by the above patch.

Keeping open to track backporting the fix to gcc 13.

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

* [Bug driver/111700] ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
  2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-10-08 23:07 ` dmalcolm at gcc dot gnu.org
@ 2024-05-09 17:12 ` cvs-commit at gcc dot gnu.org
  2024-05-10 18:54 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-09 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by David Malcolm
<dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:230f672b3ed0f64c9110ef9dba616c17d713816d

commit r13-8759-g230f672b3ed0f64c9110ef9dba616c17d713816d
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu May 9 13:09:32 2024 -0400

    diagnostics: fix ICE on sarif output when source file is unreadable
[PR111700]

    Backported from r14-4474-g94caa6a6b4bd73.

    gcc/ChangeLog:
            PR driver/111700
            * input.cc (file_cache::add_file): Update leading comment to
            clarify that it can fail.
            (file_cache::lookup_or_add_file): Likewise.
            (get_source_file_content): Gracefully handle lookup_or_add_file
            failing.

    gcc/testsuite/ChangeLog:
            PR driver/111700
            * c-c++-common/diagnostic-format-sarif-file-pr111700.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug driver/111700] ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input
  2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-05-09 17:12 ` cvs-commit at gcc dot gnu.org
@ 2024-05-10 18:54 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-05-10 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

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

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above patch for GCC 13 for the upcoming GCC 13.3

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

end of thread, other threads:[~2024-05-10 18:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05  5:27 [Bug driver/111700] New: ICE: SIGSEGV in needs_read_p (input.cc:598) with -fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr on pre-processed input zsojka at seznam dot cz
2023-10-06 13:59 ` [Bug driver/111700] " dmalcolm at gcc dot gnu.org
2023-10-08 22:50 ` cvs-commit at gcc dot gnu.org
2023-10-08 23:07 ` dmalcolm at gcc dot gnu.org
2024-05-09 17:12 ` cvs-commit at gcc dot gnu.org
2024-05-10 18:54 ` dmalcolm 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).