public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
@ 2024-03-25 18:25 zsojka at seznam dot cz
  2024-03-25 18:47 ` [Bug analyzer/114472] " dmalcolm at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2024-03-25 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114472
           Summary: [14 Regression] ICE: in falls_short_of_p, at
                    analyzer/store.cc:365 (in exceeds_p, at
                    analyzer/store.cc:342) with -fanalyzer
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 57813
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57813&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -fanalyzer testcase.c 
during IPA pass: analyzer
testcase.c: In function 'bar':
testcase.c:13:3: internal compiler error: in falls_short_of_p, at
analyzer/store.cc:365
   13 |   __builtin_strncpy(&d, &s - 3, -1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x8ca06b
ana::bit_range::falls_short_of_p(generic_wide_int<fixed_wide_int_storage<128>
>, ana::bit_range*) const
        /repo/gcc-trunk/gcc/analyzer/store.cc:365
0x28c0d6e ana::region_model::check_region_bounds(ana::region const*,
ana::access_direction, ana::svalue const*, ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/bounds-checking.cc:1438
0x19622b9 ana::region_model::check_region_access(ana::region const*,
ana::access_direction, ana::svalue const*, ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:3095
0x19622b9 ana::region_model::check_region_access(ana::region const*,
ana::access_direction, ana::svalue const*, ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:3084
0x19622b9 ana::region_model::check_region_for_read(ana::region const*,
ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:3129
0x19622b9 ana::region_model::check_region_for_read(ana::region const*,
ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:3126
0x19622b9 ana::region_model::get_store_value(ana::region const*,
ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:2690
0x19688d2 ana::region_model::get_store_value(ana::region const*,
ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:2686
0x19688d2 ana::region_model::read_bytes(ana::region const*, tree_node*,
ana::svalue const*, ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:4462
0x19688d2 ana::region_model::read_bytes(ana::region const*, tree_node*,
ana::svalue const*, ana::region_model_context*) const
        /repo/gcc-trunk/gcc/analyzer/region-model.cc:4453
0x1945a2a update_model
        /repo/gcc-trunk/gcc/analyzer/kf.cc:1609
0x193397a ana::exploded_graph::process_node(ana::exploded_node*)
        /repo/gcc-trunk/gcc/analyzer/engine.cc:4241
0x193442a ana::exploded_graph::process_worklist()
        /repo/gcc-trunk/gcc/analyzer/engine.cc:3516
0x1936b9b ana::impl_run_checkers(ana::logger*)
        /repo/gcc-trunk/gcc/analyzer/engine.cc:6210
0x1937b66 ana::run_checkers()
        /repo/gcc-trunk/gcc/analyzer/engine.cc:6308
0x1926458 execute
        /repo/gcc-trunk/gcc/analyzer/analyzer-pass.cc:87
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-r14-9652-20240325121350-gcf3fc6f414f-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/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 --enable-libsanitizer
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-9652-20240325121350-gcf3fc6f414f-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240325 (experimental) (GCC)

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
@ 2024-03-25 18:47 ` dmalcolm at gcc dot gnu.org
  2024-03-26  8:06 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-03-25 18:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-03-25
           Priority|P3                          |P1

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

Confirmed: https://godbolt.org/z/5rnoW9a3a

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
  2024-03-25 18:47 ` [Bug analyzer/114472] " dmalcolm at gcc dot gnu.org
@ 2024-03-26  8:06 ` rguenth at gcc dot gnu.org
  2024-04-09 11:41 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-26  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
  2024-03-25 18:47 ` [Bug analyzer/114472] " dmalcolm at gcc dot gnu.org
  2024-03-26  8:06 ` rguenth at gcc dot gnu.org
@ 2024-04-09 11:41 ` jakub at gcc dot gnu.org
  2024-04-09 20:06 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-09 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
strncpy (..., -1) is an always UB case; the testcase has UB already on &s - 3,
but get_next_bit_offset of -32 suggests that it is somehow adding the -3 *
BITS_PER_UNIT offset from the source and the -1 * BITS_PER_UNIT from the size. 
That is wrong,
first of all, strncpy from the source copies just at most that many bytes, in a
valid program there would need to be a '\0' far before that as one can't do
pointer arithmetics in char * past half of the address space; plus the size
isn't negative, it is positive 0xffffffffffffffffULL on x86-64.
The reason strncpy would be UB with [LONG_MAX + 1UL, ULONG_MAX] last argument
is that it then has to fill the rest of the buffer with '\0's and again the
pointer arithmetics isn't well defined in that case.

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-04-09 11:41 ` jakub at gcc dot gnu.org
@ 2024-04-09 20:06 ` dmalcolm at gcc dot gnu.org
  2024-04-10 20:47 ` cvs-commit at gcc dot gnu.org
  2024-04-10 21:00 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-04-09 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
I'm testing a fix for this.

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-04-09 20:06 ` dmalcolm at gcc dot gnu.org
@ 2024-04-10 20:47 ` cvs-commit at gcc dot gnu.org
  2024-04-10 21:00 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-10 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC 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:4a94551d7eaaf7a75c5195fc0bf4af94185a04c7

commit r14-9902-g4a94551d7eaaf7a75c5195fc0bf4af94185a04c7
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Apr 10 16:43:30 2024 -0400

    analyzer: fix ICE on negative values for size_t [PR114472]

    I made several attempts to fix this properly, but for now apply
    a band-aid to at least prevent crashing on such cases.

    gcc/analyzer/ChangeLog:
            PR analyzer/114472
            * access-diagram.cc (bit_size_expr::maybe_get_formatted_str):
            Reject attempts to print sizes that are too large.
            * region.cc (region_offset::calc_symbolic_bit_offset): Use a
            typeless svalue for the bit offset.
            * store.cc (bit_range::intersects_p): Replace assertion with
            test.
            (bit_range::exceeds_p): Likewise.
            (bit_range::falls_short_of_p): Likewise.

    gcc/testsuite/ChangeLog:
            * c-c++-common/analyzer/out-of-bounds-pr114472.c: New test.

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

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

* [Bug analyzer/114472] [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer
  2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-04-10 20:47 ` cvs-commit at gcc dot gnu.org
@ 2024-04-10 21:00 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-04-10 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

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> ---
ICE should be fixed by the above patch.

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

end of thread, other threads:[~2024-04-10 21:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-25 18:25 [Bug analyzer/114472] New: [14 Regression] ICE: in falls_short_of_p, at analyzer/store.cc:365 (in exceeds_p, at analyzer/store.cc:342) with -fanalyzer zsojka at seznam dot cz
2024-03-25 18:47 ` [Bug analyzer/114472] " dmalcolm at gcc dot gnu.org
2024-03-26  8:06 ` rguenth at gcc dot gnu.org
2024-04-09 11:41 ` jakub at gcc dot gnu.org
2024-04-09 20:06 ` dmalcolm at gcc dot gnu.org
2024-04-10 20:47 ` cvs-commit at gcc dot gnu.org
2024-04-10 21:00 ` 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).