When building libfiu on Debian 13 aarch64 with the following command:
make V=1 DEBUG=1 TRACE=1 POSIX_TRACE=1 tests
the 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.
When building libfiu on Debian 13 aarch64 with the following command:
the test programs (e.g.,
test-enable_stack_by_name.c) enter infinite recursive calls (e.g., infputc) and eventually crash. Tested with both GCC 14.2.0 and Clang 20.1.8.The root cause appears to be that the
printdmacro explicitly callsfprintf. Sinceprintdcannot access the originalfprintffunction pointer, this can lead to recursive calls whenfprintfis intercepted.I tried a simple yet effective solution: build the tracing string using
snprintfandvsnprintf, then write it directly to stderr viasyscall(SYS_write, STDERR_FILENO, ...), bypassing the intercepted functions.BTW: In
preload/posix/Makefileandpreload/run/Makefile, theCFLAGSdefaults to-O3and omits-pedantic, which is inconsistent with other Makefiles and makes debugging more difficult.