Bug 104789 - daemon re-execs itself unnecessarily on startup to disable lazy linking
Summary: daemon re-execs itself unnecessarily on startup to disable lazy linking
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: daemon (show other bugs)
Version: unspecified
Hardware: Other All
: medium minor
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-25 14:12 UTC by Vivek Dasmohapatra
Modified: 2018-01-26 02:14 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch to #if out the re-exec code when the linker supports ‘-z now’ (1.00 KB, patch)
2018-01-25 14:12 UTC, Vivek Dasmohapatra
Details | Splinter Review

Description Vivek Dasmohapatra 2018-01-25 14:12:55 UTC
Created attachment 136961 [details] [review]
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@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.
Comment 1 Tanu Kaskinen 2018-01-26 02:14:20 UTC
Thanks for the patch! I applied it now.

When sending patches to any project, I recommend that you use "git format-patch" rather than sending a plain diff. The formatted patch contains a commit message and author information, so the project maintainer doesn't have to manually write those.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.