delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/11/14/10:37:36

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:reply-to:subject:to:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=cQiZiiX9lVt+7wmM
ZH9aP2Z6c4A0HcdkHNubZV3Z22nsr+UzY7qBkqaQL4vyNGIvL8MpE7mor2RaNfY9
zEx657CC14tloydSM+ITAnLkZ3srCQrC/ctWAOZO+VnDBBZxL8vonFHiBsZleXfB
4ILiJPVPak94CwzFiIY1Actu6UA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:reply-to:subject:to:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=9cFB1u209CPlXTuwJWwnkF
9HduI=; b=EwWRw9L8c6ZjFGt0llHRM98O/utCq7s00U0vpgSpgKuM5GYC7ZSuRW
4GuZZ9aeXzE6wIADMRlhBLTec+MOivDsJZrkJaiSkmDPiddvlil7m13vfzKM5ycA
qDzI2ij98IFt9PbGchYOIE0+woTPFA87TIqS8PDQavto5i782Dsfc=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=shy, HX-Languages-Length:2848
X-HELO: smtp-out-no.shaw.ca
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Subject: Re: Question about executable startup failure
To: cygwin AT cygwin DOT com
References: <MN2PR09MB39650609A15AEC36C24F3614A5710 AT MN2PR09MB3965 DOT namprd09 DOT prod DOT outlook DOT com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Openpgp: preference=signencrypt
Message-ID: <2f141e31-fbfa-b228-38a7-58f0f909b25e@SystematicSw.ab.ca>
Date: Thu, 14 Nov 2019 08:36:41 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1
MIME-Version: 1.0
In-Reply-To: <MN2PR09MB39650609A15AEC36C24F3614A5710@MN2PR09MB3965.namprd09.prod.outlook.com>
X-IsSubscribed: yes

On 2019-11-13 23:48, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin wrote:
> Here's a situation: I have a binary that was built (from a C source code)
> with Cygwin 3.0.7 but "accidentally" used with much older Cygwin 2.11.2.
> 
> The binary won't actually launch.  Instead, it most uneventfully (silently, 
> no crash - no drama) exits with an exit code of 127, meaning "command not 
> found". The same exit code would have resulted from any mistyped command,
> which shell couldn't recognize / locate a matching file for (yet it won't be
> shy of saying so).
> 
> When I start the binary under debugger, I see the following:
> 
> [New Thread 12576.0x4d70]
> [New Thread 12576.0x4860]
> [New Thread 12576.0x44b8]
> [New Thread 12576.0x4528]
> [Thread 12576.0x44b8 exited with code 3221225785]
> [Thread 12576.0x4860 exited with code 3221225785]
> During startup program exited with code 0xc0000139.
> 
> So there's actually an explanation:  0xc0000139(=3221225785) is defined to be
> 
> ntstatus.h:#define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS)0xC0000139)
> 
> Now, the question is:  is it by design that the exit code is posted so 
> timidly?  Shouldn't there be a message that some dynamic linkage wasn't
> satisfied?
> Wouldn't 126 (which is "command cannot execute") be a better choice for the 
> exit code in this case?  Especially if the message cannot be produced at
> all?
> 
> I mean, it is actually a good thing that the executable won't start if it 
> happens to be incompatible with some random Cygwin version;  it just needs to
> be more vocal about the problem and post a more appropriate exit code, too.
> 
> Thanks,
> Anton
> 
> P.S. I didn't get to know what exactly the entry point was missing that the 
> binary required (obviously from the newer Cygwin ABI).
> 
> Reference:
> https://pubs.opengroup.org/onlinepubs/9699919799//utilities/V3_chap02.html#tag_18_08_02
> If a command is not found, the exit status shall be 127. If the command name
> is found, but it is not an executable utility, the exit status shall be
> 126. Applications that invoke utilities without using the shell should use
> these exit status values to report similar errors.

That assumes a POSIX layer is in control: with incompatible Cygwin ABI versions,
calling a missing entrypoint, Cygwin did not get far enough through startup to
detect and report the mismatch; gdb says so here:

> During startup program exited with code 0xc0000139.

so Windows handles termination.

$ fgrep -R 'During startup program exited with code' src/cygwin/newlib-cygwin/
$ fgrep -R 'During startup program exited with code' /bin/
Binary file /bin/gdb.exe matches

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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