Re: RTLD_LAZY considered harmful (Re: pltlc and pltlcu - Mailing list pgsql-hackers

From Tom Lane
Subject Re: RTLD_LAZY considered harmful (Re: pltlc and pltlcu
Date
Msg-id 18523.1013474997@sss.pgh.pa.us
Whole thread Raw
In response to Re: RTLD_LAZY considered harmful (Re: pltlc and pltlcu  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: RTLD_LAZY considered harmful (Re: pltlc and pltlcu
List pgsql-hackers
I wrote:
> I hate to sound like a broken record, but I want to re-open that
> discussion about RTLD_LAZY binding that trailed off a week or two
> ago.
> ... I therefore assert that the current coding is effectively untested
> on Linux, which is probably our most popular platform, and therefore
> it should *NOT* be accorded the respect normally due to the status
> quo.  Arguably, 7.2 has introduced breakage here.

After some further digging around on the net, I believe that coding in
the following style is safe and will work on all systems supporting
dlopen():

/** In older systems, like SunOS 4.1.3, the RTLD_NOW flag isn't defined* and the mode argument to dlopen must always be
1. The RTLD_GLOBAL* flag is wanted if available, but it doesn't exist everywhere.* If it doesn't exist, set it to 0 so
ithas no effect.*/
 
#ifndef RTLD_NOW
#   define RTLD_NOW 1
#endif

#ifndef RTLD_GLOBAL
#   define RTLD_GLOBAL 0
#endif

#define pg_dlopen(f)    dlopen((f), RTLD_NOW | RTLD_GLOBAL)


I also believe that this will produce more consistent cross-platform
behavior: so far as I could learn from googling, systems that do not
define RTLD_NOW/RTLD_LAZY all act as though the mode were RTLD_NOW,
ie, immediate binding.

Any objections to modifying all the port/dynloader files this way?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Idea for making COPY data Microsoft-proof
Next
From: Tom Lane
Date:
Subject: Re: Optimizer(?) off by factor of 3 ... ?