On 2018-02-23 11:05:23 -0500, Tom Lane wrote: > Andres Freund <and...@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.1277772...@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