[llvm-bugs] [Bug 47701] New: TestCases/Posix/strxfrm.c crashes if locale not defined
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Oct 1 05:16:26 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47701
Bug ID: 47701
Summary: TestCases/Posix/strxfrm.c crashes if locale not
defined
Product: compiler-rt
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: compiler-rt
Assignee: unassignedbugs at nondot.org
Reporter: zilla at kayari.org
CC: llvm-bugs at lists.llvm.org
This test does:
locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
n = strxfrm_l(q2, "qwerty", sizeof(q2), loc);
If newlocale fails and returns (locale_t)0 then the strxfrm_l will segfault.
The newlocale call can fail if LANG or LC_ALL is set in the environment and
refers to a locale that is not known. For example, the relevant glibc
localedata might not be installed on the system. This can happen in minimal
container environments where only a minimal set of localedata is present, but
testers might still set LANG in the environment.
A simple solution that would be easier to debug than a crash deep inside glibc
would be:
locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
assert( loc != (locale_t)0);
n = strxfrm_l(q2, "qwerty", sizeof(q2), loc);
Or include <stdio.h> and <errno.h> and:
locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
if (loc == (locale_t)0)
{
perror("newlocale failed:");
assert(loc != (locale_t)0);
}
n = strxfrm_l(q2, "qwerty", sizeof(q2), loc);
I think there are other tests with similar reliance on localedata that crash
mysteriously.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201001/1e472781/attachment.html>
More information about the llvm-bugs
mailing list