Re: RTLD_GLOBAL (& JIT inlining)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: RTLD_GLOBAL (& JIT inlining)
Date: 2018-02-26 21:28:36
Message-ID: 20180226212836.of4jm5iyxkxd2e2o@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-02-23 11:05:23 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > I think using RTLD_LOCAL on most machines would be a much better
> > idea. I've not found proper explanations why GLOBAL is used. We started
> > using it ages ago, with [2], but that commit contains no explanation,
> > and a quick search didn't show up anything either. Peter?
>
> https://www.postgresql.org/message-id/7142.1277772335@sss.pgh.pa.us
>
> My position is the same as then: I'm happy to remove it if it doesn't
> break things anywhere ... but it seems like it would cause problems for
> plpython, unless their behavior has changed since 2001 which is
> surely possible.

It hasn't, and it's not just plpython, at least plperl is affected as
well. I'd guess most libraries that have their own dynamic loading
support are affected.

So RTLD_LOCAL is out of the question, but I think we can get a good bit
of the benefit by either specifying -Wl,-Bsymbolic at shlib build time,
or RTLD_DEEPBIND at dlopen() time. Either leads to the opened shared
library effectively being put at the beginning of the search path,
therefore avoiding the issue that an earlier loaded shared library or
symbols from the main binary can accidentally overwrite things in the
shared library itself. Which incidentally also makes loading a bit
faster.

A bit of googling suggests -Bsymbolic is likely to be more portable.

A quick test confirms that under linux our tests pass with it, after
patching Makefile.shlib.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ants Aasma 2018-02-26 21:50:41 Re: RTLD_GLOBAL (& JIT inlining)
Previous Message Tom Lane 2018-02-26 21:25:25 Re: invalid memory alloc request size error with commit 4b93f579