Skip to content

Tests trigger infinite recursive calls when tracing is enabled #8

Description

@linmajia

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions