[pulseaudio-tickets] [Bug 104789] New: daemon re-execs itself unnecessarily on startup to disable lazy linking

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Jan 25 14:12:55 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=104789

            Bug ID: 104789
           Summary: daemon re-execs itself unnecessarily on startup to
                    disable lazy linking
           Product: PulseAudio
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: minor
          Priority: medium
         Component: daemon
          Assignee: pulseaudio-bugs at lists.freedesktop.org
          Reporter: vivek at collabora.co.uk
        QA Contact: pulseaudio-bugs at lists.freedesktop.org
                CC: lennart at poettering.net

Created attachment 136961
  --> https://bugs.freedesktop.org/attachment.cgi?id=136961&action=edit
Patch to #if out the re-exec code when the linker supports ‘-z now’

Hi:

While debugging an unrelated matter, I noticed that pulseaudio was
re-execing itself very soon after startup. Upon investigating further
I discovered this:

src/daemon/main.c:398
============================================================================
#if defined(__linux__) && defined(__OPTIMIZE__)
    /*
       Disable lazy relocations to make usage of external libraries
       more deterministic for our RT threads. We abuse __OPTIMIZE__ as
       a check whether we are a debug build or not. This all is
       admittedly a bit snake-oilish.
    */

    if (!getenv("LD_BIND_NOW")) {
    ⋮
    pa_set_env("LD_BIND_NOW", "1");

    if ((canonical_rp = pa_realpath(PA_BINARY))) {

        if ((rp = pa_readlink("/proc/self/exe"))) {

            if (pa_streq(rp, canonical_rp))
                pa_assert_se(execv(rp, argv) == 0)
============================================================================

However pulseaudio is linked with ‘-z now’:

vivek at noise:~$ readelf -a $(which pulseaudio) | grep NOW 
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE

So relocations will happen early anyway, making the re-exec (I believe)
unnecessary.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-bugs/attachments/20180125/08166298/attachment.html>


More information about the pulseaudio-bugs mailing list