[PATCH] Fix typo in z13 bdiv_dbm1c.

Stefan Liebler stli at linux.ibm.com
Wed Oct 4 11:06:26 CEST 2023


On 30.09.23 14:53, Torbjörn Granlund wrote:
> Stefan Liebler <stli at linux.ibm.com> writes:
> 
>   The returned limb was retrieved from v6 instead of v2.
>   This is also observable in failing testcase t-fat.
> 
> While I agree the code looks suspicious, I fail to trigger any test
> suite failure for any Z/arch configuration.
> 
> How exactly did you trigger it?
> 
> (I try to avoid fixing any GMP bugs without making sure we trigger it
> with our testsuite and test system setup.)
> 
> 
I'm using a z16 with Fedora 37 (gcc 12.2.1). There I've just run:
<gmp-sources>$ ./.bootstrap
<gmp-build-dir>$ <gmp-sources>/configure
<gmp-build-dir>$ make
<gmp-build-dir>$ make check

../../../gmp/test-driver: line 112: 2635694 Aborted
(core dumped) "$@" >> "$log_file" 2>&1
FAIL: t-fat


(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=<optimized out>, no_tid=no_tid at entry=0) at pthread_kill.c:44
#1  0x000003fff7ca1466 in __pthread_kill_internal (signo=<optimized
out>, threadid=<optimized out>) at pthread_kill.c:78
#2  0x000003fff7c51640 in __GI_raise (sig=sig at entry=6) at
../sysdeps/posix/raise.c:26
#3  0x000003fff7c345c0 in __GI_abort () at abort.c:79
#4  0x000003fff7e8de08 in __gmp_assert_fail
(filename=filename at entry=0x100c01e
"/home/stli/libgmpDir/gmp/tests/mpn/t-fat.c", linenum=linenum at entry=138,
expr=expr at entry=0x100c058 "r == 0")
    at /home/stli/libgmpDir/gmp/assert.c:57
#5  0x00000000010030ca in check_functions () at
/home/stli/libgmpDir/gmp/tests/mpn/t-fat.c:138
#6  0x0000000001002a04 in main () at
/home/stli/libgmpDir/gmp/tests/mpn/t-fat.c:305



│      133    for (i = 0; i < 2; i++)
│      134	{
│      135        xp[0] = 1296;
│      136        r = mpn_divexact_by3c (wp, xp, (mp_size_t) 1,
CNST_LIMB(0));
│      137        ASSERT_ALWAYS (wp[0] == 432);
│  >   138        ASSERT_ALWAYS (r == 0);
│      139	}

In my case, before calling mpn_divexact_by3c v6 was {0x1, 0x0} and thus
mpn_bdiv_dbm1c returns 0x1, which is ANDed with 3 and then also returned
by mpn_divexact_by3c. Therefore the test fails by chance.

I assume, you are using a different gcc version.


More information about the gmp-devel mailing list