-
Notifications
You must be signed in to change notification settings - Fork 30
Description
When building libfiu on Debian 13 aarch64 with the following command:
make V=1 DEBUG=1 TRACE=1 POSIX_TRACE=1 teststhe test programs (e.g., test-enable_stack_by_name.c) enter infinite recursive calls (e.g., in fputc) and eventually crash. Tested with both GCC 14.2.0 and Clang 20.1.8.
The root cause appears to be that the printd macro explicitly calls fprintf. Since printd cannot access the original fprintf function pointer, this can lead to recursive calls when fprintf is intercepted.
I tried a simple yet effective solution: build the tracing string using snprintf and vsnprintf, then write it directly to stderr via syscall(SYS_write, STDERR_FILENO, ...), bypassing the intercepted functions.
BTW: In preload/posix/Makefile and preload/run/Makefile, the CFLAGS defaults to -O3 and omits -pedantic, which is inconsistent with other Makefiles and makes debugging more difficult.