Bug 2238781 - Static function miscompiled at -O1 optimization level with gcc-13.2.1-1.fc39.i686
Summary: Static function miscompiled at -O1 optimization level with gcc-13.2.1-1.fc39....
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: i686
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-09-13 15:06 UTC by Petr Pisar
Modified: 2024-03-24 01:35 UTC (History)
10 users (show)

Fixed In Version: gcc-13.2.1-6.fc39 gcc-13.2.1-7.fc38
Clone Of:
Environment:
Last Closed: 2023-12-08 01:39:09 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer (1.43 KB, text/plain)
2023-09-13 15:06 UTC, Petr Pisar
no flags Details

Description Petr Pisar 2023-09-13 15:06:09 UTC
Created attachment 1988683 [details]
reproducer

When packaging zpaqfranz (bug #2238725), I discovered a segfault on i686 <https://github.com/fcorbelli/zpaqfranz/issues/71>. I believe this is caused by GCC which miscompiled a loading of an uint64_t array member passed by a pointer in static function.

If you build an attached reproducer with "gcc -O1 -g -Dunix t2.cc" on i686, and disassemble a HighwayHashReset() function, you can see that loading key[3] at the last line of the function:

  state->v1[3] = state->mul1[3] ^ ((key[3] >> 32) | (key[3] << 32));

is miscompiled like:

        movl    28(%eax), %ecx
        movl    24(%ecx), %ebx

while expected assembly code is:

        movl    28(%eax), %ecx
        movl    24(%eax), %ebx

A trigger is having the HighwayHashReset() function static and compiling with -O1. Lowering the optimization or removing the static keyword fixes the assembly code. This does not happen on other 64-bit architectures.

Comment 1 Marek Polacek 2023-09-15 17:55:23 UTC
Looks like it was fixed by https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=790c1f60a5662b16eb19eb4b81922995863c7571

commit 790c1f60a5662b16eb19eb4b81922995863c7571
Author: Roger Sayle <roger>
Date:   Thu Aug 3 07:12:04 2023 +0100

    PR target/110792: Early clobber issues with rot32di2_doubleword on i386.

The fix is not yet in GCC 13 but Sam & I asked for it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110792#c16

Comment 2 Petr Pisar 2023-09-18 08:11:05 UTC
That indeed looks similar.

Comment 3 Fedora Update System 2023-12-06 11:46:30 UTC
FEDORA-2023-1c6b112a75 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-1c6b112a75

Comment 4 Fedora Update System 2023-12-07 01:49:00 UTC
FEDORA-2023-1c6b112a75 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-1c6b112a75`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-1c6b112a75

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2023-12-08 01:39:09 UTC
FEDORA-2023-1c6b112a75 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Fedora Update System 2024-03-17 11:34:10 UTC
FEDORA-2024-a5ef56504d (gcc-13.2.1-7.fc38) has been submitted as an update to Fedora 38.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-a5ef56504d

Comment 7 Fedora Update System 2024-03-18 03:22:04 UTC
FEDORA-2024-a5ef56504d has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-a5ef56504d`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-a5ef56504d

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2024-03-24 01:35:43 UTC
FEDORA-2024-a5ef56504d (gcc-13.2.1-7.fc38) has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.