From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.187]) by sourceware.org (Postfix) with ESMTPS id 345893861893 for ; Wed, 3 Mar 2021 11:01:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 345893861893 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Myb8P-1m0IpH0pGn-00yycE; Wed, 03 Mar 2021 12:00:30 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 12044A804C1; Wed, 3 Mar 2021 12:00:25 +0100 (CET) Date: Wed, 3 Mar 2021 12:00:25 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Cc: Mark Geisert Subject: Re: segfault on 32bit cygwin snapshot Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, Mark Geisert References: <9d7b9dc2-cb92-498b-7655-e9c618114c87@gmail.com> <20210221072954.db2dcbd523ed366e4dfcb0d0@nifty.ne.jp> <7480c946-8e02-aba2-c06f-6b39f630699f@gmail.com> <20210301095546.dce31a474bd0cec2c3518f87@nifty.ne.jp> <20210301212542.8b1749f92af62c01b008f25a@nifty.ne.jp> <20210302200308.62db4fe01f78fb35a538784f@nifty.ne.jp> <20210303185621.b048287526901af6a4c8200a@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210303185621.b048287526901af6a4c8200a@nifty.ne.jp> X-Provags-ID: V03:K1:Eqp7KU3fgTUcoklgHMTLS4XEcymttxpt/qUbTQ2pzhiArVRvk5d o/9nKswBNKWGnMyIFAmgSKU8wt+/QafTl7VQb2910oUxrwPrBTHH7GodoM0SPYxL0+/ZLpB YDfx6nVBAKxIXJnQAKxtafILM6lZN8hrcAm/kp2oRA/l5FFxUOtNK1xyabF1uG7ci7Q9WLz J2lepdmIRR5Qvq7SZIVrw== X-UI-Out-Filterresults: notjunk:1;V03:K0:upJxRkW+TMY=:41JkOwJPml/TV3Dx9kPqOW 9yyI9yhqX68z2JCTGvEftnW6t24hnuN/uIfvXg0oQOHyIqilCY1OnO1wzghOId1Q78p0hBQ9n OLuQ9PQ36Zt5lGshedjXT4e0inW5g78rULubLXLJjlqVLXvvC2kHBfEEmxE2gC8yeOdFrorGE hKfQmFCroSiUuznCCFXyZa/U3fsEsS2FzEJvan0IXRmGnxKCZBnfCjRPWzCxORFWTq7s4FhHZ 6xK452Wyw0kLH3Z+/mvgIiBcaOkmQqpXAsv+S+yrq8gZOsT6ttEN4CrjR688PWPLA8ZqB+ehM YpwQcwLX5CPL43a1aaNnIa2Rf712UQobOPYR2+RMXJGDOqHXcr9BnHN0+AOJSNNN9yb+7zutB /T4W4fDNgHCLOf4u3K/iWcXN5Id6wRhgH1NzDCPsOJBSgu+1Ab13ucDNWhlNAGzjsimRZrQzK QxLF9O3dM0Y1zB1KrTqj5s9QA+bSuZyUrlKvFPjaL4BfVANBBb8n X-Spam-Status: No, score=-101.4 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2021 11:01:23 -0000 [Ping Mark Geisert] On Mar 3 18:56, Takashi Yano via Cygwin wrote: > Hi Corinna, > > On Tue, 2 Mar 2021 16:48:45 +0100 > Corinna Vinschen wrote: > > On Mar 2 20:03, Takashi Yano via Cygwin wrote: > > > > The following check code does not work as expected if > > > > newly build exe file is linked with old dll which calls > > > > uname() as in this case. > > > > > > > > if (CYGWIN_VERSION_CHECK_FOR_UNAME_X) > > > > return uname_x (in_name); > > > > > > > > Any idea? > > > > > > Ping Corinna? > > > > I have no idea how we could fix that, other than by rebuilding the DLLs > > which call uname, too. We can't check the Cygwin build of all DLLs an > > executable is linked to. > > I have checked all /usr/bin/*.dll in my cygwin installation and found > following dlls call uname() rather than uname_x(). > [...] > Do you think rebuilding all of these (or maybe more) dlls is only > the solution? No, we could also drop the above code snippet. Here's the problem: When we changed some datatypes in the early 2000s, the old entry points have been conserved for backward compatibility, while the new function using the new datatypes got a new name, e. g., stat vs. _stat64. Next, libcygwin.a gets changed so that a newly built executable (using the new datatypes as defined in the standard headers) calling stat is redirected to _stat64. All is well for the next 15+ years or so. Then we discover that the exact same mechanism fails to work for uname vs. the new uname_x in python. What happened? It turned out that python called uname dynamically Rather then just calling uname, it calls dlopen();dlsym("uname"); This actually fetches the symbol for uname, not the symbol for uname_x. The good old mechanism used for ages on standard function, fails as soon as the caller uses dynamic loading of symbols. Surprise, surprise! It was just never taken into consideration that standard libc functions might be called dynamically, given it usually doesn't make sense. Given that this affects *all* of these redirected functions, we're in a bit of a fix. Fortunately, for all other functions this only affects 32 bit Cygwin, because the 64 bit version never had this backward compatibility problem. Therefore, uname vs. uname_x is the only function affecting 64 bit Cygwin as well, and that's why I added the above crude redirection only to uname in the first place. So what we can do is this: - Either all old DLLs calling uname must be rebuilt. - Or we remove the above code snippet again and behave like for all other redirected functions on 32 bit as well. Python's os.uname is broken, but all the affected DLL sstart working again. Is there a way around that? I'm not quite sure, so let's brain storm a bit, ok? - One thing we could try is to remove the above code, but add a python hack to dlsym instead. This would let the "old" DLLs work again as before and for python we could add a hack to dlsym, along these lines: if (CYGWIN_VERSION_CHECK_FOR_UNAME_X && modulehandle == cygwin1.dll && strcmp (symname, "uname")) symname = "uname_x"; Thoughts? Other ideas? Thanks, Corinna