From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sZQkDCmEvWJQbgkAWB0awg (envelope-from ) for ; Thu, 30 Jun 2022 07:08:25 -0400 Received: by simark.ca (Postfix, from userid 112) id 1EEAC1E22B; Thu, 30 Jun 2022 07:08:25 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_DYNAMIC autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9F2121E15C for ; Thu, 30 Jun 2022 07:08:24 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 009C5386F0EF for ; Thu, 30 Jun 2022 11:08:23 +0000 (GMT) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id 32010386EC02 for ; Thu, 30 Jun 2022 11:08:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 32010386EC02 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f51.google.com with SMTP id k22so26736443wrd.6 for ; Thu, 30 Jun 2022 04:08:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=WpvhwqpvpAcM+5Ib+qlvNRVUbj6JHK+z0500sbGCfE4=; b=Y3yBzTgdnjPim7Yayt/ypWvvddQy2iAyvgc7A70vrF1nOjm30WA2ykOYWblCVg7Y7K F2UnHr9Afs4LrvbvqPykdMhT+bJpdWcWKJuq13TnumuFOqCzN+PBraKtWUk4W5m/aoMA 4dF4O+6ec3EDBPnDdAZz4kqJ46jm1atrgiWH8jkB5yp5e4daQpLBptO4gZksFfVr1ukg vMkzhxIAdMaLGh+ULG3PESFQ3PcM6Y/ok32Qdlr2H3UVyx7/x1o27tFOsDEWYF8g+CHf DHGoKRgjvZVMr5kKVAfu38F4qIuPjt+xxLQgnuKbYWP+uMrXuMmuBSvzvNUrhMOleA62 a0vg== X-Gm-Message-State: AJIora8lByytqh5t9PdVW1rrDIouxsjuiHi+nWhuGmCilBddgeaha4FQ CwPyjrCMUsHtPWToVI/dGsnUbZ9NGPM= X-Google-Smtp-Source: AGRyM1sa0rXlPctPPtKcigHf1rxX7F3c3+G7TDJglzN20IfFjZucfvKiprkq7F/dbpfeZWVCVc4clg== X-Received: by 2002:adf:fb12:0:b0:20c:79b2:a200 with SMTP id c18-20020adffb12000000b0020c79b2a200mr7965795wrr.617.1656587290100; Thu, 30 Jun 2022 04:08:10 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id u6-20020a5d5146000000b0020fcc655e4asm19489797wrt.5.2022.06.30.04.08.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jun 2022 04:08:08 -0700 (PDT) Message-ID: Date: Thu, 30 Jun 2022 12:08:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH][gdb] Block SIGTERM in worker threads Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org References: <20220630095824.GA24025@delia.home> From: Pedro Alves In-Reply-To: <20220630095824.GA24025@delia.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2022-06-30 10:58, Tom de Vries wrote: > Hi, > > With gdb build with gcc-12 and -fsanitize=thread, and test-case > gdb.base/gdb-sigterm.exp, I run into: > ... > WARNING: ThreadSanitizer: data race (pid=9722)^M > Write of size 4 at 0x00000325bc68 by thread T1:^M > #0 handle_sigterm(int) src/gdb/event-top.c:1211 (gdb+0x8ec01f)^M > ... > Previous read of size 4 at 0x00000325bc68 by main thread:^M > [failed to restore the stack]^M > ^M > Location is global 'sync_quit_force_run' of size 4 at \ > 0x00000325bc68 (gdb+0x325bc68)^M > ... > SUMMARY: ThreadSanitizer: data race gdb/event-top.c:1211 in \ > handle_sigterm(int)^M > ... > and 3 more data races involving handle_sigterm and locations: > - active_ext_lang > - quit_flag > - heap block of size 40 > (XNEW (async_signal_handler) in create_async_signal_handler) > > This was reported in PR29297. > > The testcase executes a "kill -TERM $gdb_pid", which generates a > process-directed signal. > > A process-directed signal can be delivered to any thread, and what we see > here is the fallout of the signal being delivered to a worker thread rather > than the main thread. > > Fix this by blocking SIGTERM in the worker threads. > > [ I have not been able to reproduce this after it occurred for the first time, > so unfortunately I cannot confirm that the patch fixes the problem. ] > > Tested on x86_64-linux, with and without -fsanitize=thread. > > Any comments? OK.