Re: RTLD_GLOBAL (& JIT inlining) - Mailing list pgsql-hackers

From Andres Freund
Subject Re: RTLD_GLOBAL (& JIT inlining)
Date
Msg-id 20180226212836.of4jm5iyxkxd2e2o@alap3.anarazel.de
Whole thread Raw
In response to Re: RTLD_GLOBAL (& JIT inlining)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: RTLD_GLOBAL (& JIT inlining)
List pgsql-hackers
On 2018-02-23 11:05:23 -0500, Tom Lane wrote:
> Andres Freund <andres@anarazel.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: invalid memory alloc request size error with commit 4b93f579
Next
From: Ants Aasma
Date:
Subject: Re: RTLD_GLOBAL (& JIT inlining)