Code coverarge with dynamically loaded libraries (moved)

Hello,

I am using code-coverage and address sanitizer while running unit tests. I encountered some dubious leak reports and traced the issue to the strdup call in parseFilenamePattern function from the compiler-rt library (Link).

I managed to build a reproducible test this way:

 CLARGS="-stdlib=libc++ -stdlib=libc++ -fuse-ld=lld -rtlib=compiler-rt -fsanitize=address -fsanitize=undefined -fprofile-instr-generate -fcoverage-mapping "

 echo "int foo() {return 0;}" | clang++ $CLARGS  -shared -o libfoo.so -x c++ -

 printf '#include <dlfcn.h>\nint main() {dlclose(dlopen("libfoo.so", RTLD_LOCAL | RTLD_NOW));}\n' | clang++  $CLARGS -rpath '$ORIGIN' -L. -ldl -o test -x c++ -

LLVM_PROFILE_VERBOSE=1 LLVM_PROFILE_FILE=/tmp/x.profraw ./test
LLVM Profile Note: Set profile file path to "/tmp/x.profraw" via environment variable.
LLVM Profile Note: Set profile file path to "/tmp/x.profraw" via environment variable.

=================================================================
==110334==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 15 byte(s) in 1 object(s) allocated from:
    #0 0x564d55018533 in strdup (/tmp/test+0xc7533) (BuildId: 1e04c0d508d1ff64)
    #1 0x7f96814bf485  (<unknown module>)

SUMMARY: AddressSanitizer: 15 byte(s) leaked in 1 allocation(s).

Any Tips how to handle this?
I guess I could start replacing the initializers, like outlined here.

Still the info is a bit lacking. is currently the profiling truncated, and some ready-to-run projects would be welcome.