Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJ0Wg-0001NA-7h for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Nov 2018 18:20:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gJ0Wd-000601-J9 for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Nov 2018 18:19:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJ0Wd-0005zu-4u for pgsql-hackers@lists.postgresql.org; Sat, 03 Nov 2018 18:19:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJ0WS-0004LT-JM for pgsql-hackers@postgresql.org; Sat, 03 Nov 2018 18:19:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA3IJkIo020462; Sat, 3 Nov 2018 14:19:46 -0400 From: Tom Lane To: Pavel Raiskup cc: PostgreSQL Hacker , devrim@gunduz.org Subject: Re: plruby: rb_iterate symbol clash with libruby.so In-reply-to: <4738198.8KVIIDhgEB@nb.usersys.redhat.com> References: <4738198.8KVIIDhgEB@nb.usersys.redhat.com> Comments: In-reply-to Pavel Raiskup message dated "Sat, 03 Nov 2018 17:19:40 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20460.1541269186.1@sss.pgh.pa.us> Date: Sat, 03 Nov 2018 14:19:46 -0400 Message-ID: <20461.1541269186@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavel Raiskup writes: > Hi, I'm curious how it worked before (seems like the function is defined > in both PostgreSQL and Ruby projects for quite some time) - but I recently > came across this situation: > - /bin/postgres is build-time linked with 'ld -E' > - /bin/postgres dlopen()s plruby.so > - plruby.so calls rb_iterate, but linker prefers rb_iterate defined in > /bin/postgres, instead of (the wanted one) rb_iterate from libruby.so > This means an ugly PG server crash. I'm curious what to do with this; > ideally it would be solvable from plruby.so itself, but there doesn't seem > to be nice solution (one could do some hacks with dlopen('libruby.so')). Bleah. We recently noticed that using a --version-script symbol filter on shared libraries fixes some cases of this problem, because a non-exported symbol will be preferentially resolved inside the library. I guess that's of no use for this particular case though, since evidently Ruby has to export its rb_iterate for Ruby extensions to use. > Is it realistic we could rename red-black tree methods from 'rb_*' to e.g. > 'rbt_*' to avoid this clash? That's not terribly appetizing, because it essentially means we're giving Ruby (and potentially every other library on the planet) veto power over our function namespace. That does not scale, especially not when the feedback loop has a time constant measured in years :-( I don't have a huge objection to renaming the rbtree functions, other than the precedent it sets ... regards, tom lane