[Bug 278701] Certain usage of thread_local and -fPIE results in an obscure message printout

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 02 May 2024 17:07:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278701

            Bug ID: 278701
           Summary: Certain usage of thread_local and -fPIE results in an
                    obscure message printout
           Product: Base System
           Version: 14.0-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: vd@FreeBSD.org

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.