Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Nov 2022 22:18:11 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 267671] [libc] Remove unnecessary printf to stderr in stdlib/cxa_thread_atexit_impl.c
Message-ID:  <bug-267671-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D267671

            Bug ID: 267671
           Summary: [libc] Remove unnecessary printf to stderr in
                    stdlib/cxa_thread_atexit_impl.c
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: erik@tenku.dk

This is a request to remove the printf statement in
stdlib/cxa_thread_atexit_impl.c in the function walk_cb_call.



The function signature is currently
"
static void
walk_cb_call(struct cxa_thread_dtor *dtor)
{
        struct dl_phdr_info phdr_info;

        if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
            __elf_phdr_match_addr(&phdr_info, dtor->func))
                dtor->func(dtor->obj);
        else
                fprintf(stderr, "__cxa_thread_call_dtors: dtr %p from "
                    "unloaded dso, skipping\n", (void *)(dtor->func));
}
"

and I suggest to modify it to read

"
static void
walk_cb_call(struct cxa_thread_dtor *dtor)
{
        struct dl_phdr_info phdr_info;

        if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
            __elf_phdr_match_addr(&phdr_info, dtor->func))
                dtor->func(dtor->obj);
}
"

Currently, walk_cb_call does all the necessary checks (as far as I can tell=
) in
its if-statement, calling the destructor of a given dso only if the dso has=
 not
already been unloaded.
If the dso appears multiple times as the list of dsos is iterated over in t=
he
function cxa_thread_walk (in the same source file), the error message will =
be
printed multiple times to the user.

A specific dso might very well appear multiple times in the list of dsos, i=
f it
is linked into several other dsos on which a given program relies.

The error message could perhaps be considered informative while debugging, =
but
it does not add any functionality and it potentially gives any end-user a w=
rong
impression of the integrity of a program that has this behaviour.
As such, I suggest to remove the print statement from the source code.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-267671-227>