[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tests/test-suite.log fails with musl libc 1.2.x
From: |
Bruno Haible |
Subject: |
Re: gnulib-tests/test-suite.log fails with musl libc 1.2.x |
Date: |
Sun, 17 Jan 2021 22:29:33 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) |
Hi,
Natanael Copa wrote in
<https://lists.gnu.org/archive/html/bug-gettext/2021-01/msg00021.html>:
> This happens on Alpine linux (3.13.0_rc4) on aarch64, armv7, mips64,
> ppc64le, s390x, x86 and x86_64.
>
>
> The failure is:
>
> test-canonicalize-lgpl.c:211: assertion 'strcmp (result1, "/") == 0' failed
> Aborted
> FAIL test-canonicalize-lgpl (exit status: 134)
>
> Problem is that musl realpath("//", ...) returns "//", which is allowed
> in POSIX.
>
> This fixes it:
>
> diff --git a/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
> b/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
> index ff82981..17842e8 100644
> --- a/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
> +++ b/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
> @@ -208,8 +208,8 @@ main (void)
> #ifndef __MVS__
> if (SAME_INODE (st1, st2))
> {
> - ASSERT (strcmp (result1, "/") == 0);
> - ASSERT (strcmp (result2, "/") == 0);
> + ASSERT (strcmp (result1, "/") == 0 || strcmp (result1, "//") == 0);
> + ASSERT (strcmp (result2, "/") == 0 || strcmp (result2, "//") == 0);
> }
> else
> #endif
Thanks for the report.
This failure is not reproducible on Alpine Linux 3.12; it is apparently caused
by this commit in musl libc (first released in musl libc 1.2.2):
http://git.musl-libc.org/cgit/musl/commit/?id=29ff7599a448232f2527841c2362643d246cee36
I don't agree that the test suite should be loosened for this. It is true
that POSIX allows arbitrary things to happen for file names that start
with 2 slashes. AFAIU, this is meant as a compromise for Cygwin and/or z/OS
(cf. m4/double-slash-root.m4). Making // work differently than / on Linux
is just silly and pointless.
On OSes other than Cygwin, Windows, z/OS, many applications expect that
realpath() and canonicalize_file_name() return a *canonicalized* file name,
that is, that if the result of canonicalize_file_name() on two strings is
different, the files are different (except for hard links).
So, the right fix for Gnulib is to make realpath() and canonicalize_file_name()
work like glibc does, on all Linux platforms.
The attached patches
1) add more unit tests, to check also the case with up to 3 slashes,
2) override realpath() on musl libc systems.
I experimented with a simpler override like this:
char *
rpl_realpath (const char *name, char *resolved)
# undef realpath
{
if (name == NULL)
{
errno = EINVAL;
return NULL;
}
/* Combine multiple leading slashes to a single one. */
while (name[0] == '/' && name[1] == '/')
name++;
return realpath (name, resolved);
}
but it fixes only the case where the input file name starts with two
slashes; it does not fix the case where a symlink's value starts with
two slashes. So, we have to enable the full glibc-based realpath() as
override.
3) Avoid a link error in a testdir of all of gnulib on Solaris 10:
cc -O -g -L/home/haible/prefix-x86/lib -o test-canonicalize-lgpl
test-canonicalize-lgpl.o libtests.a ../gllib/libgnu.a libtests.a
../gllib/libgnu.a libtests.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
Undefined first referenced
symbol in file
libintl_dcngettext ../gllib/libgnu.a(openat-die.o)
libintl_gettext ../gllib/libgnu.a(openat-die.o)
libintl_dcgettext ../gllib/libgnu.a(openat-die.o)
ld: fatal: symbol referencing errors. No output written to
test-canonicalize-lgpl
Bruno
0001-canonicalize-lgpl-tests-Add-more-tests.patch
Description: Text Data
0002-canonicalize-lgpl-Work-around-handling-in-realpath-o.patch
Description: Text Data
0003-canonicalize-lgpl-tests-Fix-link-error.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: gnulib-tests/test-suite.log fails with musl libc 1.2.x,
Bruno Haible <=