[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU poke 3.90.1 on musl libc
|
From: |
Bruno Haible |
|
Subject: |
Re: GNU poke 3.90.1 on musl libc |
|
Date: |
Mon, 22 Jan 2024 21:07:26 +0100 |
On Alpine Linux 3.19/x86_64, which uses musl libc, there are test failures:
Making a new site.exp file ...
WARNING: Couldn't find the global config file.
Using /home/bruno/poke-3.90.1.1/testsuite/lib/poke.exp as tool init file.
Test run by bruno on Mon Jan 22 17:33:34 2024
Native configuration is x86_64-pc-linux-musl
=== poke tests ===
Schedule of variations:
unix
Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for
target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/bruno/poke-3.90.1.1/testsuite/config/unix.exp as
tool-and-target-specific interface file.
Running /home/bruno/poke-3.90.1.1/testsuite/poke.cmd/cmd.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.libpoke/libpoke.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.map/map.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.pickles/pickles.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.pkl/pkl.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.pktest/pktest.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.pokefmt/pokefmt.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.pvm/pvm.exp ...
FAIL: poke.pvm/pvm-insns-test.pk: 31 stof: assertion failure at
/home/bruno/poke-3.90.1.1/testsuite/poke.pvm/pvm-insns-test.pk:379:9: asm
int<32>: ("stof; nn; nip" : "")
FAIL: poke.pvm/pvm-insns-test.pk: 32 stod: assertion failure at
/home/bruno/poke-3.90.1.1/testsuite/poke.pvm/pvm-insns-test.pk:401:9: asm
int<32>: ("stod; nn; nip" : "")
FAIL: ./../poke/poke: non-zero exit code: 24811 exp6 0 1
Running /home/bruno/poke-3.90.1.1/testsuite/poke.repl/repl.exp ...
Running /home/bruno/poke-3.90.1.1/testsuite/poke.std/std.exp ...
FAIL: poke.std/std-test.pk: 21 string to floating-point conversion: assertion
failure at /home/bruno/poke-3.90.1.1/testsuite/poke.std/std-test.pk:540:9:
!(stof ("") ?! E_conv)
FAIL: ./../poke/poke: non-zero exit code: 25164 exp32 0 1
Running /home/bruno/poke-3.90.1.1/testsuite/poke.time/time.exp ...
=== poke Summary ===
# of expected passes 7973
# of unexpected failures 5
# of expected failures 3
# of unsupported tests 7
make[4]: *** [Makefile:5896: check-DEJAGNU] Error 1
Find attached the testsuite/poke.sum file.
The problems appear to be with the 'stof' and 'stod' instructions. A look into
common/pk-utils.c tells me that that are implemented through the functions
'strtof' and 'strtod', respectively.
$ nm --dynamic libpoke/.libs/libpoke.so.1.0.0 | grep strto
U strtod
U strtof
U strtok
U strtol
U strtoll
U strtoull
shows that these functions are taken from libc.
More precisely, the problem is with the empty string passed as argument.
POSIX:2018
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html>
says that
"If no conversion could be performed, 0 shall be returned, and errno may be
set to [EINVAL]."
And that's precisely where the portability problem is. This program
------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
int main ()
{
const char *arg = "";
char *endptr;
errno = 0;
double result = strtod (arg, &endptr);
printf ("result = %g, endptr = arg+%d, errno = %d\n", result,
(int)(endptr-arg), errno);
}
------------------------------------------------------------------------
prints
result = 0, endptr = arg+0, errno = 0
on glibc systems but
result = 0, endptr = arg+0, errno = 22
on musl libc systems.
The Gnulib module 'strtod' does not fix this portability problem
<https://www.gnu.org/software/gnulib/manual/html_node/strtod.html>.
So, the fix needs to be in poke/common/pk-utils.c.
Now, should the empty string be treated as valid or invalid, for the
'stof' and 'stod' instructions?
IMO, it makes no sense to treat "" as valid and " " or "+" as invalid.
Only strings that contain a number should be considered as valid here.
Therefore, find attached a proposed patch. With it, "make check" passes
both on glibc and musl libc systems (Ubuntu and Alpine Linux).
Bruno
poke.sum.gz
Description: application/gzip
0001-stof-stod-Treat-the-empty-string-argument-as-invalid.patch
Description: Text Data
- Re: GNU poke 3.90.1 on musl libc,
Bruno Haible <=