public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
@ 2021-11-04 15:00 marxin at gcc dot gnu.org
  2021-11-04 15:00 ` [Bug ipa/103082] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-04 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103082
           Summary: [12 Regression] gcc/poly-int.h:1162:5: runtime error:
                    left shift of negative value -40
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: hubicka at gcc dot gnu.org, marxin at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

I see the following UBSAN error:

../../gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
    #0 0x2d20c79 in poly_int<1u, poly_result<long, long,
poly_coeff_pair_traits<long, long>::result_kind>::type> operator<< <1u, long,
int>(poly_int_pod<1u, long> const&, int const&) ../../gcc/poly-int.h:1162
    #1 0x2d20c79 in modref_access_node::contains(modref_access_node const&)
const ../../gcc/ipa-modref-tree.h:120
    #2 0x2d40293 in modref_ref_node<int>::insert_access(modref_access_node,
unsigned long, bool) ../../gcc/ipa-modref-tree.h:521
    #3 0x2d45fdd in modref_tree<int>::insert(int, int, modref_access_node,
bool) ../../gcc/ipa-modref-tree.h:848
    #4 0x2cf0b88 in record_access ../../gcc/ipa-modref.c:758
    #5 0x2d16ac1 in analyze_store ../../gcc/ipa-modref.c:1290
    #6 0x2932310 in walk_stmt_load_store_addr_ops(gimple*, void*, bool
(*)(gimple*, tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*,
tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*, void*))
../../gcc/gimple-walk.c:767
    #7 0x2cf4561 in analyze_stmt ../../gcc/ipa-modref.c:1313
    #8 0x2cf4561 in analyze_function ../../gcc/ipa-modref.c:2366
    #9 0x2cfe26d in execute ../../gcc/ipa-modref.c:3213
    #10 0x348e890 in execute_one_pass(opt_pass*) ../../gcc/passes.c:2567
    #11 0x3491f51 in execute_pass_list_1 ../../gcc/passes.c:2656

one can see it easily with:

diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h
index 9976e489697..65875d9539f 100644
--- a/gcc/ipa-modref-tree.h
+++ b/gcc/ipa-modref-tree.h
@@ -116,6 +116,7 @@ struct GTY(()) modref_access_node
               if (!known_le (parm_offset, a.parm_offset)
                   && !range_info_useful_p ())
                 return false;
+              gcc_checking_assert ((a.parm_offset - parm_offset).to_constant
() >= 0);
               aoffset_adj = (a.parm_offset - parm_offset)
                             << LOG2_BITS_PER_UNIT;
            }

$ cat d2s.i
long mulShift(long *mul) { return mul[0] + mul[1]; }

$ gcc d2s.i -c -O2
during GIMPLE pass: modref
d2s.i: In function ‘mulShift’:
d2s.i:1:1: internal compiler error: in contains, at ipa-modref-tree.h:119
    1 | long mulShift(long *mul) { return mul[0] + mul[1]; }
      | ^~~~
0xcce4a9 modref_access_node::contains(modref_access_node const&) const
        /home/marxin/Programming/gcc/gcc/ipa-modref-tree.h:119
0xcce4a9 modref_access_node::contains(modref_access_node const&) const
        /home/marxin/Programming/gcc/gcc/ipa-modref-tree.h:101
0xcd1912 modref_ref_node<int>::insert_access(modref_access_node, unsigned long,
bool)
        /home/marxin/Programming/gcc/gcc/ipa-modref-tree.h:523
0xcd25ce modref_tree<int>::insert(int, int, modref_access_node, bool)
        /home/marxin/Programming/gcc/gcc/ipa-modref-tree.h:850
0xcc5d62 record_access
        /home/marxin/Programming/gcc/gcc/ipa-modref.c:758
0xcccb73 analyze_load
        /home/marxin/Programming/gcc/gcc/ipa-modref.c:1262
0xc1df93 walk_stmt_load_store_addr_ops(gimple*, void*, bool (*)(gimple*,
tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*,
void*), bool (*)(gimple*, tree_node*, tree_node*, void*))
        /home/marxin/Programming/gcc/gcc/gimple-walk.c:800
0xcc6b9c analyze_stmt
        /home/marxin/Programming/gcc/gcc/ipa-modref.c:1313
0xcc6b9c analyze_function
        /home/marxin/Programming/gcc/gcc/ipa-modref.c:2366
0xcc8991 execute
        /home/marxin/Programming/gcc/gcc/ipa-modref.c:3213
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined

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

* [Bug ipa/103082] [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
  2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
@ 2021-11-04 15:00 ` marxin at gcc dot gnu.org
  2021-11-04 16:41 ` hubicka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-04 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.0
   Target Milestone|---                         |12.0

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

* [Bug ipa/103082] [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
  2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
  2021-11-04 15:00 ` [Bug ipa/103082] " marxin at gcc dot gnu.org
@ 2021-11-04 16:41 ` hubicka at gcc dot gnu.org
  2021-11-04 19:39 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-04 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-11-04
           Assignee|unassigned at gcc dot gnu.org      |hubicka at gcc dot gnu.org

--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The compuation is supposed to be working for negative values. Later we add the
bitoffset which can make it positive again and range check will match. 

The computation is correct on any complement of two host and we do not really
support others I believe, but I guess changing it to *HOST_BITS_PER_UNIT is
easiest way to get ubsan quiet?

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

* [Bug ipa/103082] [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
  2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
  2021-11-04 15:00 ` [Bug ipa/103082] " marxin at gcc dot gnu.org
  2021-11-04 16:41 ` hubicka at gcc dot gnu.org
@ 2021-11-04 19:39 ` jakub at gcc dot gnu.org
  2021-11-05 22:18 ` cvs-commit at gcc dot gnu.org
  2021-11-05 22:26 ` hubicka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-04 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

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> ---
Shifting a negative value left is well defined in C++20, but undefined in C++11
.. C++17.
I guess one possibility would be to cast to poly_uint64 and back, another one
would be to do (a.parm_offset - parm_offset) * BITS_PER_UNIT and let the
compiler optimize it.

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

* [Bug ipa/103082] [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
  2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-04 19:39 ` jakub at gcc dot gnu.org
@ 2021-11-05 22:18 ` cvs-commit at gcc dot gnu.org
  2021-11-05 22:26 ` hubicka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-05 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:

https://gcc.gnu.org/g:9cc8ca8da90426f625481195a2127a5e86689bcd

commit r12-4965-g9cc8ca8da90426f625481195a2127a5e86689bcd
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Nov 5 23:17:50 2021 +0100

    Avoid left shift of negative value in ipa-modref-tree.h

    gcc/ChangeLog:

            PR ipa/103082
            * ipa-modref-tree.h (struct modref_access_node): Avoid left shift
            of negative value

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

* [Bug ipa/103082] [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40
  2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-11-05 22:18 ` cvs-commit at gcc dot gnu.org
@ 2021-11-05 22:26 ` hubicka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-05 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

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

--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-11-05 22:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 15:00 [Bug ipa/103082] New: [12 Regression] gcc/poly-int.h:1162:5: runtime error: left shift of negative value -40 marxin at gcc dot gnu.org
2021-11-04 15:00 ` [Bug ipa/103082] " marxin at gcc dot gnu.org
2021-11-04 16:41 ` hubicka at gcc dot gnu.org
2021-11-04 19:39 ` jakub at gcc dot gnu.org
2021-11-05 22:18 ` cvs-commit at gcc dot gnu.org
2021-11-05 22:26 ` hubicka 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).