Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 370FC1465A38 for ; Wed, 30 May 2012 18:43:52 -0300 (ADT) Received: from [2001:1528:137::f1] (helo=mail.gransy.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SZqgI-0000NY-F1 for pgsql-bugs@postgresql.org; Wed, 30 May 2012 21:43:51 +0000 Received: from antispam.gransy.com (antispam.gransy.com [77.78.104.124]) by mail.gransy.com (Postfix) with ESMTP id 0DCBF5088CC; Wed, 30 May 2012 23:43:36 +0200 (CEST) Received: from mail.gransy.com ([82.208.44.189]) by antispam.gransy.com (antispam.gransy.com [77.78.104.124]) (amavisd-new, port 10024) with ESMTP id SpGOONg63z72; Wed, 30 May 2012 23:43:35 +0200 (CEST) Received: by mail.gransy.com (Postfix, from userid 5000) id F0557508905; Wed, 30 May 2012 23:43:35 +0200 (CEST) Received: from [192.168.1.237] (ip-78-45-133-255.net.upcbroadband.cz [78.45.133.255]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id B74775088CC; Wed, 30 May 2012 23:43:35 +0200 (CEST) Message-ID: <4FC69487.7000106@fuzzy.cz> Date: Wed, 30 May 2012 23:43:35 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120420 Thunderbird/12.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: overwriting an existing .so while being used crashes the server process References: <4FC6833C.6080501@fuzzy.cz> <8227.1338410155@sss.pgh.pa.us> <4FC68C3B.4060609@fuzzy.cz> <9187.1338412749@sss.pgh.pa.us> In-Reply-To: <9187.1338412749@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:1528:137::f1 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201205/231 X-Sequence-Number: 33202 On 30.5.2012 23:19, Tom Lane wrote: > I suspect it depends on how you install the new version of the library, > too. I would somewhat expect it to work as you're thinking if the > install consists of "rename old file out of the way, copy new file into > place, unlink old file" or equivalent. If you are actually > *overwriting* the file in place, a crash does not seem especially > surprising --- it would make perfect sense if the kernel expects the > file to be usable as backing store for the in-memory image, which is not > exactly unreasonable. IOW, if the in-memory bits we're executing are > just an mmap'd image of the .so file, changing the .so file could > entirely be expected to lead to a crash. Aha! That might be the culprit - I've just tested that deleting the olf file and copying new version (thus not overwriting it) did not cause a crash. Funny. >> http://www.postgresql.org/docs/9.1/interactive/xfunc-c.html > >> After it is used for the first time, a dynamically loaded object >> file is retained in memory. Future calls in the same session to the >> function(s) in that file will only incur the small overhead of a >> symbol table lookup. If you need to force a reload of an object >> file, for example after recompiling it, begin a fresh session. > >> Which kinda looks like my expectation that the session won't crash was >> correct. Clearly seems like bug to me. > > No, that just means that we don't unload it from memory. Where the bits > actually are, and whether the kernel has defenses against somebody > modifying the executable, is not something you should be asking us. > Talk to a kernel hacker for your platform. OK, thanks for the explanation. I still think it's worth mentioning this issue in the docs ... Tomas