[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1086581: stringencoders: FTBFS on riscv64 due to undefined signed integer overflow



Source: stringencoders
Version: 3.10.3+git20180306-1.1
Severity: serious
Tags: ftbfs patch upstream
Justification: fails to build from source (but built successfully in the past)
X-Debbugs-Cc: debian-riscv@lists.debian.org
User: debian-riscv@lists.debian.org
Usertags: riscv64

Dear maintainer,

stringencoders fails to build on riscv64:

| =================================================
|    stringencoders v3.10.3: test/test-suite.log
| =================================================
| 
| # TOTAL: 16
| # PASS:  15
| # SKIP:  0
| # XFAIL: 0
| # FAIL:  1
| # XPASS: 0
| # ERROR: 0
| 
| .. contents:: :depth: 2
| 
| FAIL: modp_numtoa_test
| ======================
| 
| modp_numtoa_test.c ........ASSERTION FAILED: modp_numtoa_test.c:408 -2147483648 != -0./,),(-*,(
| FAIL modp_numtoa_test (exit status: 1)
| 
| ============================================================================
| Testsuite summary for stringencoders v3.10.3
| ============================================================================
| # TOTAL: 16
| # PASS:  15
| # SKIP:  0
| # XFAIL: 0
| # FAIL:  1
| # XPASS: 0
| # ERROR: 0
| ============================================================================
| See test/test-suite.log
| Please report to nickg -at- client9 -dot- com
| ============================================================================
| make[4]: *** [Makefile:1246: test-suite.log] Error 1
| make[4]: Leaving directory '/<<PKGBUILDDIR>>/test'
| make[3]: *** [Makefile:1354: check-TESTS] Error 2
| make[3]: Leaving directory '/<<PKGBUILDDIR>>/test'
| make[2]: *** [Makefile:1532: check-am] Error 2
| make[2]: Leaving directory '/<<PKGBUILDDIR>>/test'
| make[1]: *** [Makefile:403: check-recursive] Error 1
| make[1]: Leaving directory '/<<PKGBUILDDIR>>'
| dh_auto_test: error: make -j4 check "TESTSUITEFLAGS=-j4 --verbose" VERBOSE=1 returned exit code 2
| make: *** [debian/rules:8: build-arch] Error 25
| dpkg-buildpackage: error: debian/rules build-arch subprocess returned exit status 2

The full build log is available there:
https://buildd.debian.org/status/fetch.php?pkg=stringencoders&arch=riscv64&ver=3.10.3%2Bgit20180306-1.1%2Bb2&stamp=1730377520&raw=0

The issue happens to be due to an undefined behaviour due to signed
integer overflow, triggered by the switch from GCC 13 to GCC 14. This
can be reproduced on amd64 by compiling the library with
-fsanitize=signed-integer-overflow and then running the test by hand.

The patch belows fixes the issue:

--- stringencoders-3.10.3+git20180306.orig/src/modp_numtoa.c
+++ stringencoders-3.10.3+git20180306/src/modp_numtoa.c
@@ -35,7 +35,7 @@ size_t modp_itoa10(int32_t value, char*
 {
     char* wstr = str;
     /* Take care of sign */
-    uint32_t uvalue = (value < 0) ? (uint32_t)(-value) : (uint32_t)(value);
+    uint32_t uvalue = (value < 0) ? -((uint32_t)value) : (uint32_t)(value);
     /* Conversion. Number is reversed. */
     do
         *wstr++ = (char)(48 + (uvalue % 10));
@@ -65,7 +65,7 @@ size_t modp_uitoa10(uint32_t value, char
 size_t modp_litoa10(int64_t value, char* str)
 {
     char* wstr = str;
-    uint64_t uvalue = (value < 0) ? (uint64_t)(-value) : (uint64_t)(value);
+    uint64_t uvalue = (value < 0) ? -((uint64_t)value) : (uint64_t)(value);
 
     /* Conversion. Number is reversed. */
     do

Regards
Aurelien


Reply to: