From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110890 invoked by alias); 25 Jul 2019 12:12:17 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 110883 invoked by uid 89); 25 Jul 2019 12:12:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_05,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_JMF_BL autolearn=no version=3.3.1 spammy=8.2.1-1, sk:getpgrp, UD:getpgrp_test.c, UD:getpgrp_test.exe X-HELO: rgout05.bt.lon5.cpcloud.co.uk Received: from rgout0502.bt.lon5.cpcloud.co.uk (HELO rgout05.bt.lon5.cpcloud.co.uk) (65.20.0.223) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jul 2019 12:12:15 +0000 X-OWM-Source-IP: 86.158.32.11 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-SNCR-VADESECURE: CLEAN Received: from [192.168.1.102] (86.158.32.11) by rgout05.bt.lon5.cpcloud.co.uk (9.0.019.26-1) (authenticated as jonturney@btinternet.com) id 5C24804F1373B3F7 for cygwin@cygwin.com; Thu, 25 Jul 2019 13:12:11 +0100 Subject: Re: Can't debug bash with gdb 8.2.1-1 To: The Cygwin Mailing List References: <37d412b3-f0ff-b079-4d64-16b01898b420@cornell.edu> <73dcccf2-33a0-7608-269b-e9cb9abc2238@dronecode.org.uk> <10d70ba8-41a8-10e8-0ab0-5be526931de7@cornell.edu> <69e822c7-d02c-170c-9fed-c0972df16438@cornell.edu> From: Jon Turney Message-ID: Date: Thu, 25 Jul 2019 12:12:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2019-07/txt/msg00218.txt.bz2 On 24/07/2019 15:42, Ken Brown wrote: > 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? Well spotted. > 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. Great. Thanks very much for looking into this. I guess I need to look into gdb to see if it's trying to use -1 due to some other problem, or just expects that to be ignored. -- 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