Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1C0ntE86516 for ; Mon, 11 Feb 2002 19:49:55 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g1C0nvf18526 for ; Mon, 11 Feb 2002 19:49:57 -0500 (EST) To: pgsql-hackers@postgresql.org Subject: Re: RTLD_LAZY considered harmful (Re: pltlc and pltlcu In-reply-to: <25459.1013389242@sss.pgh.pa.us> References: <25459.1013389242@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 10 Feb 2002 20:00:42 -0500" Date: Mon, 11 Feb 2002 19:49:57 -0500 Message-ID: <18523.1013474997@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/411 X-Sequence-Number: 18717 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 it has 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