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:from:to:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; q=dns; s=default; b=SOIYYhFpXM0Rgv41yHUPTI9SJ74/O /WQwvJy03XImFPLpqHwYe9vSp66xQWrx/B/vgZpvvdd1FAfyQ6+05vA+Fs4rVm8P 41H3hqUaariOPyAki5KD/Lrh5PO367msGhZuLHq+7/wE03cqgEySSkhUPPNGQl+k IFRbUQ6J5TkBnc= 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:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; s=default; bh=hz/JXhb8v4/vTgqDky1EbMjphBc=; b=k3l pa65aN3fvJACfOEPLNjnUekBysnIAu6i+JJP0D1BX7HEd/++g9e9IDg9UxaZ2G1+ 0cLBSAr8IapFqlSaYanmXHQp/3KGcA3LbOu7A2+PNV5Ts8lYXMiJc+ZfqCn47Tzf JScjFUfiZuaEZKl4NIp7Wp/UtJADnrS3JVHyN8k0= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=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, sk:getpgrp, UD:getpgrp_test.c, UD:getpgrp_test.exe X-HELO: NAM05-CO1-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=my5VhFZJIPg94TZDX56/ke6QqsUV+A+cRvaj9gJKQpACg/D5AXKIPCsyKRaExnTSgM6Dd1FbKaiEUOg3J2FSHudyRz17zCGlMKrbMwWNHfowJE/2ptZVfgZIghYn04+5Zd4kmDIjLlsH3NHOng/MDEPjEzPxjY+K6xgogrdjqEQm5TJJQJRatUDRiPu2GwILQozEent66qfIskZSN6k70Tz/dAzDrCbGiUNNZgRBHitXXryCuKLZ3y96BEDaKlKMN7BljYLmWdIOhtogkBMV5mA/g+Il3vQHOLoWPbThgooZ3Q9p2UE8F/qxfNegRCWSbkYKE7ZLHYJNwo6rABi1Eg== 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=fP28HnomZvTd3u0JM+pOK4LiZIPWj41ak5IVV5/WJRY=; b=KmSxIYUw6FUp8A1Pg2/mtukU5TZgJ12vGssDmpdZavI9+7FW4qM6b9S2sEHPQftVnYf/LS16jKk87syUbHH/6E03FXchCNNlCxzjGAHMHzZ34Q/RRw2DrmXAGQKRPqynLiSqGv/Aqv3f4vn9kjh59I7mDaC/N0txcLg+be8405c0ITBUVlgBTtM8GDGAK79G+hVHb5dqciWSyUynlIYUUWMQPdKxHi98S1ERQyYuXTufsFgP7ym9NbdN/AR2+2x1qsT3C4V7n9sI2L47Jfqhl/NXRzfJvOjlBeFzDWR9BonPcY23qZwV6zqB4ExHLvVAENDh3JIfsthvd2KQ9F2wCw== 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=fP28HnomZvTd3u0JM+pOK4LiZIPWj41ak5IVV5/WJRY=; b=jWcbnGKB/cug8aIHkPddkD6TvnVWT+Br/unJ4MOnzhXU7i4kR8I82nsfaY4WxwNjdc6eks/OFNMMM8WpBcNuIYsxNeygnWLISq/tJdlsT3kl+PhpwsOGUOVQHJCEWAQG/nywgd8LsVD0JFQgafbXPWy0qNPvb7bikndIOdH6Gpg= From: Ken Brown To: "cygwin AT cygwin DOT com" Subject: Re: Can't debug bash with gdb 8.2.1-1 Date: Wed, 24 Jul 2019 14:42:29 +0000 Message-ID: References: <37d412b3-f0ff-b079-4d64-16b01898b420 AT cornell DOT edu> <73dcccf2-33a0-7608-269b-e9cb9abc2238 AT dronecode DOT org DOT uk> <10d70ba8-41a8-10e8-0ab0-5be526931de7 AT cornell DOT edu> <69e822c7-d02c-170c-9fed-c0972df16438 AT cornell DOT edu> In-Reply-To: <69e822c7-d02c-170c-9fed-c0972df16438@cornell.edu> 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 AT cornell DOT edu; x-ms-oob-tlc-oobclassifiers: OLM:418; 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: <44C63234A504824FA2A2EBD16F5B3654 AT namprd04 DOT prod DOT outlook DOT com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ksb2 AT cornell DOT edu X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id x6OEh6W9001799 On 7/24/2019 10:32 AM, Ken Brown wrote: > On 7/24/2019 8:33 AM, Ken Brown wrote: >> $ cat getpgrp_test.c >> #include >> #include >> #include >> >> int >> main () >> { >> pid_t pid = getpid (); >> pid_t pgid = getpgid (0); >> printf ("getpid () = %d, getpgid (0) = %d, errno = %d\n", pid, pgid, errno); >> } >> >> $ gcc -o getpgrp_test -Wall -g -O0 getpgrp_test.c >> >> $ ./getpgrp_test.exe >> getpid () = 1424, getpgid (0) = 1424, errno = 0 >> >> $ gdb ./getpgrp_test.exe >> GNU gdb (GDB) (Cygwin 8.2.1-1) 8.2.1 >> [...] >> (gdb) r >> Starting program: /home/kbrown/Documents/programming/misc_examples/getpgrp_test.exe >> [...] >> getpid () = 1427, getpgid (0) = -1, errno = 0 >> [...] >> [Inferior 1 (process 23872) exited normally] >> >> So getpgid (0) returns -1 without setting errno. I think this means that >> pinfo::init() didn't fail, but for some reason myself->pgid == -1. > > I just ran the above gdb session under strace and found several lines like this: > > 25 32828861 [main] gdb 1799 tcsetpgrp: 0 = tcsetpgrp(0, -1) > > I haven't looked at the gdb code, but doesn't this mean that gdb is trying to > set pgrp to -1? If so, why? And shouldn't tcsetpgrp return -1 with EINVAL? I just looked at the gdb commit that Jon pointed to earlier in the thread. It adds calls like this: result = tcsetpgrp (0, getpgid (inf->pid)); It then checks for errors and takes appropriate action. But tcsetpgrp returns success. So this all seems to boil down to the fact that Cygwin's tcsetpgrp() doesn't check the validity of its second argument. 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