X-Recipient: archive-cygwin@delorie.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:from:to:cc:subject:date:message-id:references
	:in-reply-to:content-type:content-id:content-transfer-encoding
	:mime-version; q=dns; s=default; b=TyE5jwY5BflDrsQINm0/42tumDy77
	EV4l+njtJ9vlYC2Gyo8lMcLKTE5myA34/UIs3V0+1gEFuaSqiCqidzGd3V+3nPat
	3Fqd3+BbPEF0ZC5AWU8UehSHHdROQUwEDXcUymzSC1glNGcPjNkk7BBjiU+p0trW
	3cfVHYxQ00KBPY=
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:from:to:cc:subject:date:message-id:references
	:in-reply-to:content-type:content-id:content-transfer-encoding
	:mime-version; s=default; bh=AYZ+rQR4y30V/d+dVc/k6XLRZQ4=; b=eA4
	futYCT3t0eVwz9ty91k4n/Fz2pcKBPakX0UAohRHyOQ3t8Ek1rZlanY854sx/EOE
	mik4RatDKPHC39ZULVTeq40zXRsGsoPnr6qJWSqa7X5cmnNN1JZZ79uvfWpCwugK
	Daf3tVfin5ZaF86CuXLnS6JrBsrLgWQPyLXmifH8=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=BAYES_00,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SEM_URI,SEM_URIRED,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.1 spammy=8.2.1-1, 8211, Can't, Cant
X-HELO: NAM02-BL2-obe.outbound.protection.outlook.com
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToSbtocw7695qCnYFn938AphghdvSb86rjTz/qo7hCUDjmm1AWX9UfqTz5DoP8cpdvFsWYyttsZxzPH6h6b/7X3nQ8Uf5k6JZuFOKkHROd/UxWr/gVA45qtEH+LbXCkog+i1EP+iVWMFSCvPymCYDeHCReHFtphYXvC+J3iFq9l+9eij1ACHurcJDLQLrD1dv3o2bcaKaDyQ4DrdG0o/ntghKrxnrMBbcUPCz1xCh7aHFQafYL/fmIhRuz2obVuxao/Q55fTtMyWPCZIp8ONDENFS4Vmm3excGnhBGnb4XgWCCC8XaduKeuVM+Kr8grz2LpXN+xWGjev1Y7Ch0Dqfg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bVijGRwCUAM5Z72yWKCIRtwx8FynL3zxoFWUFJTKGZs=; b=W7IobA/Y6/BO/rhOmIhK+TnRg5cDR8rdrGtivWjqwu60H4MS0p4S0jH9CVykMWJCsw1qKucNlji+j6feGOB19lFCnVk+aDlknQJ0GuAkTK5OjCaXF1DfUB7VuHvl5CGW0Ox4ZFFDs2MHKneUM4LIB6o+0x3+J9y8x9FQ8WdtLAG2YZNdJzaQtZcYyirZPBOSlGjTpa3kmbiSn1jMVfLj9fRw5cFMuiM04ZXd7GR/D/X2e0y1vm5VV6p5eNSyoAAdaIa4cTEH8khA5/jCyO3TOltdtOpIhfFaZwlEteYoqAyf/jW++8APTGvM1lmDUO7UhGW8Zscgl1Ue5m9qVM44yA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=cornell.edu;dmarc=pass action=none header.from=cornell.edu;dkim=pass header.d=cornell.edu;arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bVijGRwCUAM5Z72yWKCIRtwx8FynL3zxoFWUFJTKGZs=; b=E/eF7qnMtA3/NCHLYAwT7rJ2Sikn+iUWoMPOUUpVs/vQRnbQR+Dy0H4aJGOO5VN4OhS7e5n+GXupAN6rOqavBrCRyzzmap1x88NsKqAKFfbwHsnU+0WZRg9h7JyhX3rxhPdxmfaNnJyHoICLV4/25yE3JAJ97NUmjql9yZqkGT0=
From: Ken Brown <kbrown@cornell.edu>
To: Jon Turney <jon.turney@dronecode.org.uk>,
        The Cygwin Mailing List	<cygwin@cygwin.com>
CC: Eric Blake <eblake@redhat.com>
Subject: Re: Can't debug bash with gdb 8.2.1-1
Date: Tue, 23 Jul 2019 15:42:19 +0000
Message-ID: <10d70ba8-41a8-10e8-0ab0-5be526931de7@cornell.edu>
References: <37d412b3-f0ff-b079-4d64-16b01898b420@cornell.edu> <73dcccf2-33a0-7608-269b-e9cb9abc2238@dronecode.org.uk>
In-Reply-To: <73dcccf2-33a0-7608-269b-e9cb9abc2238@dronecode.org.uk>
user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown@cornell.edu;
x-ms-oob-tlc-oobclassifiers: OLM:8882;
received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts)
x-ms-exchange-senderadcheck: 1
Content-Type: text/plain; charset="utf-8"
Content-ID: <827527381F79FE439D15F57021DD32D4@namprd04.prod.outlook.com>
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: ksb2@cornell.edu
X-IsSubscribed: yes
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id x6NFh8cZ008091

On 7/23/2019 9:51 AM, Jon Turney wrote:
> On 22/07/2019 15:59, Ken Brown wrote:
>> With the test version of gdb, attempting to debug bash fails as follows:
>>
>> $ gdb bash
>> GNU gdb (GDB) (Cygwin 8.2.1-1) 8.2.1
>> [...]
>> Reading symbols from bash...Reading symbols from
>> /usr/lib/debug//usr/bin/bash.exe.dbg...done.
>> done.
>> (gdb) r -c ls
>> Starting program: /usr/bin/bash -c ls
>> [...]
>> /usr/bin/bash: initialize_job_control: getpgrp failed: No error
>> [...]
>> [Inferior 1 (process 31876) exited with code 01]
>>
>> This problem doesn't occur with gdb-8.1.1-1.
> Thanks for reporting this.
> 
> I had also tripped over this problem recently: It seems that changes in gdb 
> (bisection lands on [1]) mean that any call to getpgrp() in the inferior fails 
> (this can be demonstrated with a test program that just calls that).

I can't reproduce that with the following test program:

$ cat getpgrp_test.c
#include <unistd.h>
int
main ()
{
   pid_t t = getpgrp ();
}

> I believe this is behaviour is caused by some kind of defect in the cygwin DLL, 
> but I haven't made much progress in investigating it. (I don't really understand 
> how the inferior gets into a state where getpgrp() fails, which isn't really 
> supposed to happen...)

POSIX says that getpgrp() never fails, but Cygwin's getpgrp() can in fact fail. 
I'm about to send a proposed fix to cygwin-patches.  I've just checked that the 
bash example succeeds with my patch installed.

BTW, I think there's also a bash bug here.  The bash-4.4.12 source code has the 
following in jobs.c:

   shell_pgrp = getpgid (0);

   if (shell_pgrp == -1)
     {
       sys_error (_("initialize_job_control: getpgrp failed"));
       exit (1);
     }

At first glance this might seem OK, since getpgid() is allowed to fail.  But a 
macro earlier in the code redefines getpgid() in terms of getpgrp(), which is 
not supposed to fail.

I've added Eric to the CC in case he wants to follow up on this.

Ken

--
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


