freefall:~$ cat > main.cc #include <string> thread_local std::string s; int main(int argc, char** argv) { s = "aaa"; return 0; } freefall:~$ c++ -fPIE main.cc -o main freefall:~$ ./main __cxa_thread_call_dtors: dtr 0x820b65830 from unloaded dso, skipping freefall:~$ Same result with FreeBSD-14.0/clang-16.0.6 and FreeBSD-15.0/clang-18.1.4 The printed message is obscure because it is not clear if there is a bug in the program or in the library or if I am supposed to do something to resolve the problem. Also, I think, the destructor of `s` is not called. The message is printed from walk_cb_call() from lib/libc/stdlib/cxa_thread_atexit_impl.c.
https://reviews.freebsd.org/D45074
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=b27eb9ce96b838622e125fd969e8dc4914aabe18 commit b27eb9ce96b838622e125fd969e8dc4914aabe18 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-05-03 09:32:01 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-05-03 23:23:15 +0000 __cxa_thread_call_dtors(3): fix dtor pointer validity check When checking for the destructor pointer belonging to some still loaded dso, do not limit the possible dso to the one instantiated the destructor. For instance, dso could set up the dtr pointer to a function from libcxx. PR: 278701 Reported by: vd Reviewed by: dim, emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45074 lib/libc/stdlib/cxa_thread_atexit_impl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I started investigating this from here: https://groups.google.com/g/bsdmailinglist/c/22ncTZAbDp4/m/Dii_pII5AwAJ I am not sure if that comment has merit. If that is an issue, it is different than the one from this bug report.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=6a8ca2ff53389c36233e5e0b1576696d34b74407 commit 6a8ca2ff53389c36233e5e0b1576696d34b74407 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-05-03 09:32:01 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-05-10 07:49:10 +0000 __cxa_thread_call_dtors(3): fix dtor pointer validity check PR: 278701 (cherry picked from commit b27eb9ce96b838622e125fd969e8dc4914aabe18) lib/libc/stdlib/cxa_thread_atexit_impl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5cf78a5500345340771f7eb840724c2422b2ff96 commit 5cf78a5500345340771f7eb840724c2422b2ff96 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-05-03 09:32:01 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-05-10 07:49:36 +0000 __cxa_thread_call_dtors(3): fix dtor pointer validity check PR: 278701 (cherry picked from commit b27eb9ce96b838622e125fd969e8dc4914aabe18) lib/libc/stdlib/cxa_thread_atexit_impl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)