From patchwork Wed Aug 30 19:14:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 22426 Received: (qmail 37764 invoked by alias); 30 Aug 2017 19:14:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 37755 invoked by uid 89); 30 Aug 2017 19:14:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=pts X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 Aug 2017 19:14:22 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8EEE4DAFB for ; Wed, 30 Aug 2017 19:14:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D8EEE4DAFB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jan.kratochvil@redhat.com Received: from host1.jankratochvil.net (ovpn-117-146.ams2.redhat.com [10.36.117.146]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EC559817C for ; Wed, 30 Aug 2017 19:14:20 +0000 (UTC) Date: Wed, 30 Aug 2017 21:14:17 +0200 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch+8.0.1] Fix T-stopped detach regression on old kernels Message-ID: <20170830191417.GA24482@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) Hi, https://sourceware.org/bugzilla/show_bug.cgi?id=22046 On <=RHEL6 hosts Fedora/RHEL GDB started to 'kill -STOP' all processes it detached. Even those not originally T-stopped. This is a Fedora-specific patch which is based on upstream GDB's PROC_STATE_STOPPED state. I believe (I did not verify) this patch did regress it: commit d617208bb06bd461b52ce041d89f7127e3044762 Author: Pedro Alves Date: Mon Jul 25 12:42:17 2016 +0100 linux-procfs: Introduce enum proc_state As originally there was strstr() but now there is strcmp() and so the missing trailing '\n' no longer matches. The Bug was found by Michal Kolar. Reproducibility: $ gdb -p $PID (gdb) quit $ ... Actual results: === RHEL6.9 x86_64 # scl enable devtoolset-7 bash RHEL6.9 x86_64 # which gdb /opt/rh/devtoolset-7/root/usr/bin/gdb RHEL6.9 x86_64 # ./testcase.sh 24737 pts/0 S+ 0:00 /bin/sleep 4 24737 pts/0 T+ 0:00 /bin/sleep 4 RHEL6.9 x86_64 # === Expected results: === RHEL6.9 x86_64 # which gdb /usr/bin/gdb RHEL6.9 x86_64 # ./testcase.sh 24708 pts/0 S+ 0:00 /bin/sleep 4 24708 pts/0 S+ 0:00 /bin/sleep 4 ./testcase.sh: line 20: kill: (24708) - No such process RHEL6.9 x86_64 # === Tested: 5b86dbf4549af98c4428da4764182e03f22c58ab OK for check-in? Jan 2017-08-30 Jan Kratochvil * nat/linux-procfs.c (parse_proc_status_state): Fix PROC_STATE_STOPPED detection. diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index a12f6228cb..cca35cbf1d 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -104,10 +104,10 @@ parse_proc_status_state (const char *state) return PROC_STATE_TRACING_STOP; case 'T': /* Before Linux 2.6.33, tracing stop used uppercase T. */ - if (strcmp (state, "T (tracing stop)") == 0) - return PROC_STATE_TRACING_STOP; - else + if (strcmp (state, "T (stopped)\n") == 0) return PROC_STATE_STOPPED; + else /* "T (tracing stop)\n" */ + return PROC_STATE_TRACING_STOP; case 'X': return PROC_STATE_DEAD; case 'Z':