Skip to content

[TSAN] The right way to test Python bindings around C library with TSan #1856

Description

@ivankochin

Hello!

We have a C project which is wrapped by Python interfaces using SWIG. We have both C/C++ and Python tests and want to test all of them with TSan enabled. After some investigation we discovered that after compiling our dynamic library with -fsanitize=thread we have the following picture:

  • Our dynamic library uses many __tsan_... symbols but doesn't contain this symbols and doesn't have explicit dependency on libtsan.so so it seems like it should load all these symbols at runtime
  • Our C/C++ tests which are binary executables contains all these __tsan_... symbols which are required by library, so when we run C/C++ tests everything works fine (library uses symbols from test)
  • When we test our Python wrapper, we need to set LD_PRELOAD=<path_to_libtsan.so> before running the tests since in this case we have no executable which provides us all the required symbols. But it can be tricky to understand what exact libtsan.so was used during the compilation if we have several of them in the environment.

So here come the questions:

  • Is it correct way to run our Python tests (setting LD_PRELOAD=<path_to_libtsan.so>) ?
  • Is there a more native way to do this?
  • Is there any way to determine exactly which libasan.so was used during compilation?

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions