Skip to content

msan false positive on FreeBSD in isprint() after setlocale() #65532

Open
@tavianator

Description

@tavianator

The following program:

$ cat foo.c
#include <ctype.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>

int main(void) {
        setlocale(LC_ALL, "C.UTF-8");
        return isprint(0x7F);
}

when compiled with clang16 -fsanitize=memory on FreeBSD:

$ clang16 --version
clang version 16.0.6
Target: x86_64-portbld-freebsd13.1
Thread model: posix
InstalledDir: /usr/local/llvm16/bin
$ clang16 -g -fsanitize=memory foo.c -o foo
$ elfctl -e +noaslr ./foo # Work around https://github.com/llvm/llvm-project/issues/53256

crashes with a use-of-uninitialized-value error that (I hope) is wrong:

$ ./foo
==21589==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x10bf805 in __sbmaskrune /usr/include/_ctype.h:109:2
    #1 0x10bf4c9 in __sbistype /usr/include/_ctype.h:122:12
    #2 0x10bf336 in main /usr/home/tavianator/code/bfs/foo.c:8:9

SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/include/_ctype.h:109:2 in __sbmaskrune
Exiting

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions