delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/03/04/04:05:42

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7769398E469
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1614848738;
bh=Qqc4jQ20HNId8036Izugwptr+PdfK62oPjfBtIfwSPU=;
h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=QXzXKBUqFMP4pYPndbpRPbDKK5FJOfRiVNDOBWiZqGBNC43HelFD6rJmvElYhKN5x
Id7oqcraryaozG3sD37PmaLiWUkl06mj5LNjtTt5j996UCAiS5c0Y6PXIU0MN9gb4X
HU61zARWL5qTYEDJK0DxxpA+GO1lQ7dNcmUssraM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C9B35386F455
DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 12495LoB002885
X-Nifty-SrcIP: [118.243.85.178]
Date: Thu, 4 Mar 2021 18:05:34 +0900
To: cygwin AT cygwin DOT com
Subject: Re: segfault on 32bit cygwin snapshot
Message-Id: <20210304180534.7c3825e6ee989a2bf62f0652@nifty.ne.jp>
In-Reply-To: <YD9sSea32T7GqlJr@calimero.vinschen.de>
References: <9d7b9dc2-cb92-498b-7655-e9c618114c87 AT gmail DOT com>
<20210221072954 DOT db2dcbd523ed366e4dfcb0d0 AT nifty DOT ne DOT jp>
<7480c946-8e02-aba2-c06f-6b39f630699f AT gmail DOT com>
<20210301095546 DOT dce31a474bd0cec2c3518f87 AT nifty DOT ne DOT jp>
<20210301212542 DOT 8b1749f92af62c01b008f25a AT nifty DOT ne DOT jp>
<20210302200308 DOT 62db4fe01f78fb35a538784f AT nifty DOT ne DOT jp>
<YD5eXbxBWbUUSwcM AT calimero DOT vinschen DOT de>
<20210303185621 DOT b048287526901af6a4c8200a AT nifty DOT ne DOT jp>
<YD9sSea32T7GqlJr AT calimero DOT vinschen DOT de>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, 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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Takashi Yano via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

Hi Corinna,

On Wed, 3 Mar 2021 12:00:25 +0100
Corinna Vinschen wrote:
> [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?

It sounds very reasonable to me to deal with it within dlsym(),
as the problem arises from the use of dlsym(). However, what
happens if newly built .exe is linked to old dll which calls
uname() via dlsym()? I am not sure whether there are such dlls.

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019