This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Can't debug bash with gdb 8.2.1-1
- From: Ken Brown <kbrown at cornell dot edu>
- To: Jon Turney <jon dot turney at dronecode dot org dot uk>, The Cygwin Mailing List <cygwin at cygwin dot com>
- Cc: Eric Blake <eblake at redhat dot com>
- Date: Tue, 23 Jul 2019 15:42:19 +0000
- Subject: Re: Can't debug bash with gdb 8.2.1-1
- 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
- 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-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==
- References: <37d412b3-f0ff-b079-4d64-16b01898b420@cornell.edu> <73dcccf2-33a0-7608-269b-e9cb9abc2238@dronecode.org.uk>
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