#287

Operations on signalling NaNs don't set floating-point exception bit in the musl port

Openbhaibleopened 3mo ago

Operations on signalling NaNs, unlike on plain NaNs, should set <fenv.h> floating-point exception bits. In Fil-C, they don't.

Version: filc-0.681-linux-x86_64

How to reproduce: Compile and run this program.

foo.c.gz

$ gcc -Wall foo.c -lm
$ ./a.out
$ .../filc-0.681-linux-x86_64/build/bin/filcc -g -Wall foo.c
$ ./a.out
foo.c:459: assertion 'fetestexcept (FE_INVALID)' failed
filc user error: abort() called
    (libpizlo.so) <runtime>: zerror
    (libc.so) src/exit/abort.c:13:9: abort
    (a.out) foo.c:459:5: main
    (libc.so) src/env/__libc_start_main.c:79:7: __libc_start_main
    (libpizlo.so) <runtime>: start_program
[2860413] filc panic: user thwarted themselves.
Trace/breakpoint trap      (core dumped) ./a.out

Activity

1
pizlonator3mo ago

Your test passes just fine with the glibc build of Fil-C (like the /opt/fil distro):

pizlo@death:~/Programs/fil-c-2$ build/bin/clang -o foo2 foo2.c -O2 -g -lm
pizlo@death:~/Programs/fil-c-2$ ./foo2

I confirmed that it fails with the musl distro:

pizlo@death:~/Programs/fil-c-2$ ../fil-c-4/build/bin/clang -o foo2 foo2.c -O2 -g -lm
pizlo@death:~/Programs/fil-c-2$ ./foo2 
foo2.c:459: assertion 'fetestexcept (FE_INVALID)' failed
filc user error: abort() called
    (libpizlo.so) <runtime>: zerror
    (libc.so) src/exit/abort.c:13:9: abort
    (foo2) foo2.c:459:5: main
    (libc.so) src/env/__libc_start_main.c:79:7: __libc_start_main
    (libpizlo.so) <runtime>: start_program
[46012] filc panic: user thwarted themselves.
Trace/breakpoint trap

The issue is that my musl port is currently wired up in such a way that all fexyz functions are no-ops. I should definitely fix that for fetestexcept, since I can't imagine that one being unsafe.