Skip to content

Timestamp not recognized when libasan.so is preloaded #513

Description

@cartier

I have an app that needs to be tested with a fixed date so I wrap it with faketime.
That works fine unless the app was built with Address Sanitizer (-fsanitize).
ASAN requires its shared object to be loaded first but doing so causes faketime to fail to parse the timestamp string.

$ gcc -fsanitize=address hello.c -o hello

$ ./hello
hello world

$ faketime "2021-08-19 12:00:00" ./hello

==1176412==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.

OK, so lets use LD_PRELOAD.

Find libasan.so
$ gcc -print-file-name=libasan.so
/usr/lib/gcc/x86_64-linux-gnu/13/libasan.so

LD_PRELOAD=$(gcc -print-file-name=libasan.so) faketime "2021-08-19 12:00:00" ./hello
Error: Timestamp to fake not recognized, please re-try with a different timestamp.

The timestamp used works fine with any non-ASAN executable:
$ faketime "2021-08-19 12:00:00" date
Thu Aug 19 12:00:00 PM EDT 2021

But not when ASAN is preloaded:
$ LD_PRELOAD=$(gcc -print-file-name=libasan.so) faketime "2021-08-19 12:00:00" date
Error: Timestamp to fake not recognized, please re-try with a different timestamp.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble

$ faketime --version

faketime: Version 0.9.10

Identical results are seen when building the latest version v0.9.12 from github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions