Discussion:
test-duplocale crashes
Bruno Haible
2016-10-16 18:10:35 UTC
Permalink
On a glibc system (glibc 2.15, Linux 3.8) I get this test failure
from a gnulib testdir:

./../build-aux/test-driver: line 107: 6269 Segmentation fault "$@" > $log_file 2>&1
FAIL: test-duplocale

FAIL test-duplocale (exit status: 139)

(gdb) where
#0 0x00007ffff7a4aa6f in freelocale () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x0000000000400d36 in main () at test-duplocale.c:116

The locale to be freed is NULL; this is an invalid argument to freelocale().
It's better to fix the test in this case:


2016-10-16 Bruno Haible <***@clisp.org>

Fix a test crash.
* tests/test-duplocale.c (main): Skip the test if the 'newlocale' call
fails.

diff --git a/tests/test-duplocale.c b/tests/test-duplocale.c
index 498e31d..667b3e2 100644
--- a/tests/test-duplocale.c
+++ b/tests/test-duplocale.c
@@ -72,6 +72,11 @@ main ()

/* Use a per-thread locale. */
perthread = newlocale (LC_ALL_MASK, "es_ES.UTF-8", NULL);
+ if (perthread == NULL)
+ {
+ fprintf (stderr, "Skipping test: Spanish Unicode locale is not installed\n");
+ return 77;
+ }
uselocale (perthread);

/* Save the locale in a locale_t object again. */
Pádraig Brady
2016-10-16 22:06:41 UTC
Permalink
Post by Bruno Haible
On a glibc system (glibc 2.15, Linux 3.8) I get this test failure
FAIL: test-duplocale
FAIL test-duplocale (exit status: 139)
(gdb) where
#0 0x00007ffff7a4aa6f in freelocale () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x0000000000400d36 in main () at test-duplocale.c:116
The locale to be freed is NULL; this is an invalid argument to freelocale().
Fix a test crash.
* tests/test-duplocale.c (main): Skip the test if the 'newlocale' call
fails.
diff --git a/tests/test-duplocale.c b/tests/test-duplocale.c
index 498e31d..667b3e2 100644
--- a/tests/test-duplocale.c
+++ b/tests/test-duplocale.c
@@ -72,6 +72,11 @@ main ()
/* Use a per-thread locale. */
perthread = newlocale (LC_ALL_MASK, "es_ES.UTF-8", NULL);
+ if (perthread == NULL)
+ {
+ fprintf (stderr, "Skipping test: Spanish Unicode locale is not installed\n");
+ return 77;
+ }
uselocale (perthread);
+1

Loading...