Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 922195 - sys-devel/gcc-14: miscompiles dev-libs/libgcrypt-1.10.3-r1
Summary: sys-devel/gcc-14: miscompiles dev-libs/libgcrypt-1.10.3-r1
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: gcc-14
  Show dependency tree
 
Reported: 2024-01-16 07:08 UTC by Sam James
Modified: 2024-01-22 04:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-16 07:08:43 UTC
Started recently - I think between 14-20231217 5060825aa78b3da036df6437390fd42d094d8f15 and 14-20240114 5f6557b3c61134c762fa442e4f711317c372f364.

I don't have a better guess than that yet because of all the vectorisation churn (partial break support landed in 14-20231224 a657c7e3518fcfc796f223d47385cad5e97dc9a5 and it's needed followups since).

Only happens for me with -O3 -march=znver2 -m32.

(Note that I also see a dev-libs/gmp miscompilation but I've, for now, started with libgcrypt as the test case looks a bit better.)

```
t-mpi-point: context_alloc: tv[0].'NIST P-521': sample point multiply failed:
          k: 7FFFFFE0003F00000007F00007FFFF80000000001FFC000000FFF030001F03E8FFFFF3E8003803E8000003EA003F0467FFFFF3E8000003E800FFE3E800000000
         Qx: 7CAACB2174E1A97A63BABF4E9E6E82389898A1607E4737672B1070E5F66535E406455BFD70F2EBEEEF3F2DB9303E8DB3941190575849708A456188899714C96E74
expected Qx: 00C1002DC2884EEDADB3F9B468BBEBD55980799852C506D37271FFCD006919DB3A96DF8FE91EF6ED4B9081B1809E8F2C2B28AF5FCBF524147C73CB0B913D6FAB0995
         Qy: 00990438D2386F13AC4FC5BE2F8690FC5BC1B3F5A312FD113D0DF71AD01C755A89C393087575588707247E45C22931BA45B1B9B02BE8049CD2B487CF68666DDD38D2
expected Qy: 01614E8A62C8293DD2AA6EF27D30974A4FD185019FA8EF4F982DA48698CECF706581F69EE9ED67A9C231EC9D0934D0F674646153273BCBB345E923B1EC1386A1A4AD
t-mpi-point: context_alloc: tv[1].'NIST P-521': sample point multiply failed:
          k: 03FFF7FFFFFFFFFFFFFFE007FFFFFFE3FFFFFFFFFC01FFE0001FE02000FFFF000100000100FFFFC00100000080FFFFF040F8000001000000C100000000
         Qx: 00A416B8B436A53456DBB98262BF27B80E80F9F0CA440CE867A80E56B486686837ECC41F557D4098D348EADCB8C9F05AE072EE631CE6979BA63269B698500C8F8002
expected Qx: 0172CD22CBE0634B6BFEE24BB1D350F384A945ED618ECAD48AADC6C1BC0DCC107F0FFE9FE14DC929F90153F390C25BE5D3A73A56F9ACCB0C72C768753869732D0DC4
         Qy: 44D7D325D0CDEB1714AB1EE6BD62A166A2953E9799B706B49917402ACE58FF06CE207022D212958F596B0D94511FD5EC61185B6FF46B9ECBBFFBC6B1806CFCA674
expected Qy: 00D249CFB570DA4CC48FB5426A928B43D7922F787373B6182408FBC71706E7527E8414C79167F3C999FF58DE352D238F1FE7168C658D338F72696F2F889A97DE23C5
FAIL: t-mpi-point
```
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-16 07:09:55 UTC
I managed to reduce at least the test itself quite a bit so far:

$ git diff --stat 88cacf20894b41fa271522040962030390a1e416..HEAD tests/t-mpi-point.c
 tests/t-mpi-point.c | 4268 ++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 file changed, 82 insertions(+), 4186 deletions(-)

the test itself isn't miscompiled, so need to start looking at which TU in libgcrypt is broken
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 00:23:29 UTC Comment hidden (obsolete)
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 05:40:51 UTC
My earlier bisect was bad.

New result:
```
There are only 'skip'ped commits left to test.
The first bad commit could be any of:
411de96dbf2bdafc7a90ebbfc63e68afd6388d29
6cb155a6cf314232248a12bdd395ed4151ae5a28
99c0a540d6689ede068f9ba98af6f38c3cd71362
We cannot bisect more!
error: bisect run cannot continue any more
```
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 09:42:13 UTC
mpi-add.o is miscompiled
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-17 09:45:34 UTC
(In reply to Sam James from comment #4)
> mpi-add.o is miscompiled

_gcry_mpi_add_ui
Comment 6 Larry the Git Cow gentoo-dev 2024-01-19 07:45:12 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=a1e21703f86e5d60a68a53839774535ccdb8403e

commit a1e21703f86e5d60a68a53839774535ccdb8403e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-01-19 07:44:41 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-01-19 07:44:41 +0000

    14.0.0: add 76_all_PR113467-vect-miscompile.patch
    
    Bug: https://gcc.gnu.org/PR113467
    Bug: https://bugs.gentoo.org/922195
    Signed-off-by: Sam James <sam@gentoo.org>

 14.0.0/gentoo/76_all_PR113467-vect-miscompile.patch | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Comment 7 Larry the Git Cow gentoo-dev 2024-01-22 04:56:46 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77a9314cece73d71ceec164369789b08e744a252

commit 77a9314cece73d71ceec164369789b08e744a252
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-01-22 04:56:08 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-01-22 04:56:30 +0000

    sys-devel/gcc: add 14.0.1_pre20240121
    
    Includes a workaround for bug #922195.
    
    Closes: https://bugs.gentoo.org/922195
    Closes: https://bugs.gentoo.org/922580
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gcc/Manifest                      |  1 +
 sys-devel/gcc/gcc-14.0.1_pre20240121.ebuild | 64 +++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)