From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id BB2BF3858D20 for ; Wed, 21 Feb 2024 21:11:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB2BF3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BB2BF3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708549862; cv=none; b=stYdx7kpxv0GgIQeMy1DN5T8mOip1Rc4cgr94KXVp6iPV+cYhteLEgtDttrIIEvsVA0waJu2O6YcAVcg8LHjzTfa7ZPjCrqGXFyoDtyRxyk68JZq+2BNNROVFXUq5eSFHG46Mn5g4O12TutON3X/J6m/033XDpKEvwX60oUNMtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708549862; c=relaxed/simple; bh=/nEHajDvvzAc5JTuwH1corfO9sUChEFCYwfw7d9zZuc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rKTQdNDC79dfYzckE7jlPBnstZAbxvOvB8NqHBjS9airNokpWhjXdRTX2p/nSrB30DUpaXieLe3yKh0TR8Dgaa0RSnuyW8fr1B2M5WSdIw6zZ6uhbyZZIixX6r2qt5noSqSkTgOG8Jnit6QkXsrxFnwC3hR5rPLckPWTVRSsn4Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id csyEr88S0CF6Gctrnrzc0h; Wed, 21 Feb 2024 21:10:59 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id ctrmr96HUXMnWctrnrFUMs; Wed, 21 Feb 2024 21:10:59 +0000 X-Authority-Analysis: v=2.4 cv=IqgYcq/g c=1 sm=1 tr=0 ts=65d666e3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=zstS-IiYAAAA:8 a=tNYt594_tlpcALWPfAwA:9 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jDz8otvKJ1EvBXL6Du5Wpi9queGuTzQ71VFYb1XDLPM=; b=FySSBy1bUXh3gb01yxT80wU+3y KyTak9lsJwhlv5nEapHHyBbKT35saNdOAIo8O1svmNLccBqWJB0bVYpRB5S7t4UChQ57RpP6x2BJp DPcNo5qpKWLq60b8HeVGF6ojU; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:51396 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rctrm-004Iia-25; Wed, 21 Feb 2024 14:10:58 -0700 From: Tom Tromey To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 3/3] [gdb/dap] Fix race between dap exit and gdb exit References: <20240221132023.15147-1-tdevries@suse.de> <20240221132023.15147-3-tdevries@suse.de> X-Attribution: Tom Date: Wed, 21 Feb 2024 14:10:57 -0700 In-Reply-To: <20240221132023.15147-3-tdevries@suse.de> (Tom de Vries's message of "Wed, 21 Feb 2024 14:20:23 +0100") Message-ID: <87wmqxzfoe.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.170.195 X-Source-L: No X-Exim-ID: 1rctrm-004Iia-25 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net (murgatroyd) [71.211.170.195]:51396 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJMTTwmT+vo8KzeC6SKozd8z6UUP9IZeaIcuGSOnluQIJ0Y7bbKZaUzzGg8JTmG9es1E+K5Rc5RPwDkNAccQ1ruccwcdkyUsYq7hhD+FzOaVzrZdFOl8 Ji3nq1TwMaCqDgscvKzldibfqMLu7JrtCI3bDmRcL8GaYVJK9poAyO0t+jEo/ofg36OXhtkyr+8txRg2PJtwmrMVPBXHeGNZjsA= X-Spam-Status: No, score=-3016.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Tom" == Tom de Vries writes: Tom> When DAP shuts down due to an EOF event, there's a race between: Tom> - gdb's main thread handling a SIGHUP, and Tom> - the DAP main thread exiting. Tom> Fix this by waiting for DAP's main thread exit during the gdb_exiting event. Tom> Tested on aarch64-linux. Thanks, this is ok. Approved-By: Tom Tromey Tom> - start_thread("DAP", really_start_dap) Tom> + # Note that we set _dap_thread in both the DAP and the GDB main thread. Tom> + global _dap_thread Tom> + _dap_thread = start_thread("DAP", really_start_dap) Tom> +@in_gdb_thread Tom> +def _on_gdb_exiting(event): Tom> + if _dap_thread is None: Tom> + # This can happen if the DAP module is imported, but the server not Tom> + # started. Tom> + thread_log("no dap thread to join") Tom> + return Tom> + Tom> + thread_log("joining dap thread ...") Tom> + _dap_thread.join() Tom> + thread_log("joining dap thread done") Tom> + Tom> + Tom> +gdb.events.gdb_exiting.connect(_on_gdb_exiting) Originally I'd just pictured something like: local = start_thread("DAP", ...) gdb.events.gdb_exiting.connect(local.join) ... but wanting logging makes sense I suppose. The global could still be removed if you care by a nested function. Tom