<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - TestCases/Posix/strxfrm.c crashes if locale not defined"
href="https://bugs.llvm.org/show_bug.cgi?id=47701">47701</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>TestCases/Posix/strxfrm.c crashes if locale not defined
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zilla@kayari.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>