From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4721 invoked by alias); 3 Feb 2020 14:30:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 4602 invoked by uid 89); 3 Feb 2020 14:30:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 spammy=Connection, killing, 2266 X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Feb 2020 14:30:25 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 782072046F; Mon, 3 Feb 2020 09:30:23 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 12FE220393; Mon, 3 Feb 2020 09:30:21 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id AE0432816C; Mon, 3 Feb 2020 09:30:20 -0500 (EST) X-Gerrit-PatchSet: 3 Date: Mon, 03 Feb 2020 14:30:00 -0000 From: "Tankut Baris Aktemur (Code Review)" To: Tom de Vries , gdb-patches@sourceware.org Cc: Mihails Strasuns , Pedro Alves Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v3] [gdb/threads] Fix hang in stop_all_threads after killing inferior X-Gerrit-Change-Id: Ibe1f29251fe2ff1c1991f041babbe18373c113b1 X-Gerrit-Change-Number: 759 X-Gerrit-ChangeURL: X-Gerrit-Commit: 72327ba33578eb6f1adf90ac2dcc6b413f4a5766 In-Reply-To: References: X-Gerrit-Comment-Date: Mon, 3 Feb 2020 09:30:20 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 Message-Id: <20200203143020.AE0432816C@gnutoolchain-gerrit.osci.io> X-SW-Source: 2020-02/txt/msg00042.txt.bz2 Tankut Baris Aktemur has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/759 ...................................................................... Patch Set 3: I've tried this patch in two scenarios. One is when multi-threading is enabled (executable is multi.out), and the other is when the program is single-threaded (executable is named single1.out and single2.out -- exactly the same copies just to distinguish the processes). The test program is sleep.c from the PR. I start the multi-threaded case as follows: $ gdb -ex "set prompt (master-gdb) " -ex "b stop_all_threads" -ex r -ex \ "shell killall -9 multi.out" -ex c --args gdb -ex "set debug infrun 1" \ -ex r --args multi.out When gdb stops, I try "info inferiors" and "info threads" commands: Thread 1 received signal SIGINT, Interrupt. 0x00007ffff78a99d0 in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6 infrun: infrun_async(0) (gdb) i inferiors Num Description Connection Executable * 1 process 12979 1 (native) /path/to/multi.out (gdb) i threads Id Target Id Frame * 1 Thread 0x7ffff7fe3740 (LWP 12979) 0x00007ffff78a99d0 in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6 2 Thread 0x7ffff77c4700 (LWP 12996) Couldn't get registers: No such process. (gdb) thread 2 [Switching to thread 2 (Thread 0x7ffff77c4700 (LWP 12996))] Couldn't get registers: No such process. (gdb) i threads Couldn't get registers: No such process. (gdb) thread 1 Couldn't get registers: No such process. The second scenario is similar, except that instead of a multi-threaded single process, we have two single-threaded processes. Started as $ gdb -ex "set prompt (master-gdb) " -ex "b stop_all_threads" -ex r -ex c \ -ex c -ex "shell killall -9 single1.out" -ex c --args gdb -ex "set debug infrun 1" \ -ex start -ex "add-inferior -exec ./single2.out" -ex "inferior 2" -ex "start" \ -ex "set schedule-multiple on" -ex c --args ./single1.out The behavior is this: (gdb) info inferiors Num Description Connection Executable 1 process 2266 1 (native) /path/to/single1.out * 2 process 2282 1 (native) /path/to/single2.out (gdb) info threads Id Target Id Frame 1.1 process 2266 Couldn't get registers: No such process. (gdb) inferior 1 [Switching to inferior 1 [process 2266] (/path/to/single1.out)] [Switching to thread 1.1 (process 2266)] Couldn't get registers: No such process. (gdb) info inferiors Num Description Connection Executable Couldn't get registers: No such process. (gdb) info threads Couldn't get registers: No such process. (gdb) So, I think at this point it boils down to the discussion covered in https://sourceware.org/ml/gdb-patches/2020-01/msg00212.html and https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/133 GDB is not able to handle disappeared processes gracefully. The maintainers may consider the fix for the hanging behavior (i.e. the infinite loop) OK and the weird post-behavior above as a separate problem to be addressed later, but my understanding from Pedro's comment was that the deeper problem of GDB not handling already-gone processes well shall be addressed. Thanks -Baris -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: Ibe1f29251fe2ff1c1991f041babbe18373c113b1 Gerrit-Change-Number: 759 Gerrit-PatchSet: 3 Gerrit-Owner: Tom de Vries Gerrit-Reviewer: Pedro Alves Gerrit-Reviewer: Tom de Vries Gerrit-CC: Mihails Strasuns Gerrit-CC: Tankut Baris Aktemur Gerrit-Comment-Date: Mon, 03 Feb 2020 14:30:20 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment