llvm-project/compiler-rt/test
Kamil Rytarowski c22867f5fc Correct ctype(3) functions with NLS on NetBSD
Summary:
The setlocale(3) function reloads the ctype(3) arrays from
external files. This happens behind the scenes in the internals
of libc (citrus library, runes functions etc).

ctype(3) functions like isspace(3) can be provided with two
variations on NetBSD: inlined or via a global symbol in libc:

```
#if defined(_NETBSD_SOURCE) && !defined(_CTYPE_NOINLINE) && \
    !defined(__cplusplus)
#include <sys/ctype_inline.h>
#else
#include <sys/ctype_bits.h>
#endif
```

The in-lined versions are de-facto array lookup operations.

```
#define isspace(c)      ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_S))
```

After setting setlocale(3) the ctype(3) arrays (_ctype_tab_,
_toupper_tab_, _tolower_tab_) are reload behind the scenes
and they are required to be marked as initialized.

Set them initialized inside the common setlocale(3) interceptor.

The arrays are of size of 257 elements: 0..255 + 1 (EOF).

This corrects errors on NetBSD/amd64 in applications
prebuilt with MSan.

Sponsored by <The NetBSD Foundation>

Reviewers: vitalybuka, dvyukov, joerg

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D42020

llvm-svn: 326008
2018-02-24 01:01:14 +00:00
..
BlocksRuntime
asan [asan] Add "arm64" into the list of 64-bit architectures 2018-02-15 22:14:36 +00:00
builtins These tests require x86 80-bit doubles. Mark them so. 2017-12-04 18:18:51 +00:00
cfi [ubsan] Re-commit: lit changes for lld testing, future lto testing. 2017-12-01 19:36:29 +00:00
dfsan [mips] XFAIL dfsan's custom.cc test on mips64. 2017-05-09 19:17:16 +00:00
esan [tsan] Update unittest for logging changes of r308637 2017-07-20 20:06:00 +00:00
fuzzer [NFC] fix trivial typos in comments 2018-01-22 07:51:37 +00:00
hwasan [hwasan] An LLVM flag to disable stack tag randomization. 2018-01-13 01:32:15 +00:00
interception Revert "[interception] Check for export table's size before referring to its elements." 2017-01-22 03:30:14 +00:00
lsan [lsan] Respect log_path option in standalone LSan 2018-01-22 09:30:27 +00:00
msan Fix racy msan test 2018-02-21 18:03:50 +00:00
profile Update test counter_promo_nest.c to meet llvm change 2018-02-08 07:15:49 +00:00
safestack Factor out "stable-runtime" feature and enable it on all android. 2017-10-10 23:37:26 +00:00
sanitizer_common Correct ctype(3) functions with NLS on NetBSD 2018-02-24 01:01:14 +00:00
scudo [scudo] Use -fsanitize=scudo rather than --whole-archive in tests 2018-01-18 20:02:56 +00:00
tsan Correct a typo in tsan_pthread_setname_np in the FreeBSD code 2018-02-10 14:44:12 +00:00
ubsan [Sanitizers, test] Fix sanitizer tests on Solaris (PR 33274) 2018-01-17 12:26:04 +00:00
ubsan_minimal [Sanitizers, test] Fix sanitizer tests on Solaris (PR 33274) 2018-01-17 12:26:04 +00:00
xray Try to fix the syntax in test 2018-02-22 07:17:01 +00:00
CMakeLists.txt Allow compiler-rt test targets to work with multi-config CMake generators 2017-11-13 12:57:54 +00:00
lit.common.cfg Force lit to execute the ASan and TSan tests on iOS devices 2018-01-20 02:07:30 +00:00
lit.common.configured.in [ubsan] Re-commit: lit changes for lld testing, future lto testing. 2017-12-01 19:36:29 +00:00