From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Tom Tromey 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 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: , X-List-Received-Date: Thu, 30 Jun 2022 11:08:12 -0000 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.