From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 7F9653858CDA for ; Fri, 28 Jul 2023 18:10:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F9653858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-348f5193c12so8318445ab.2 for ; Fri, 28 Jul 2023 11:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1690567822; x=1691172622; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=z4S8uwC/Q4okzO5VPZudgFMT+gUXWyHxi6kUhGEPfIo=; b=HT6yV6BVPk6Q9nduB34FNf0Lc8PRP93Hgu703OBh3HN5xXkiQ8zvWisZnj8lySD9A3 O+FTK5+kabQiiPGBQnSfx2IOFeOESLuxDsezPX4v24PvDySu71BfuGiQykzthwda3ohw L5ONZ3UUlqHAk/OcoDXRN5O65qsSFK0JFwo0NjsGzdcqGTcWVxtNfJHt7H0JWf+FVsiC clRN8Cwf6x+Y5xnlZE+CqN+t69/N1UDw3ywhcNcS6wywF3vItbupMCJmDDojsktYNPA/ yFYTkwU6fPDFSS95b4Pi18EYJqq2/mwEsQtEmsvwiZBG0WUsIBboS7Yv3yKD2JpwEvIj gQTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690567822; x=1691172622; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z4S8uwC/Q4okzO5VPZudgFMT+gUXWyHxi6kUhGEPfIo=; b=TMn39QkRZG4s8x9+8oDyikZiGFgmoZ5ZCT6Ll4dXfANWYOtvDIvlGWBd6ozd58DftD 2bOFXcSxE2qPANTA/f4HvAQ3z+m+P0bXYBljfOEBU04IGWinNn13FqXowTOkGxfyVeQX DQlVRIh0A7K0D9YDzRhkKZmEf0UIcG/8Nhcz3Xu80RBXexXvTANYIlnsoOD+yqJAyK7/ QT78Uu5O2kZtvYiz02CK/hbIn02o14MfJvJBUbHPLRYFGV1VgRzNCa49ZBj6jiT0Pfb/ r1gka4s/y6JArYjpxHsvEONooEfiNx3eBQxPbqoTjbfnzum3jvOu6jF8ZaM2XnxqygRc YLDA== X-Gm-Message-State: ABy/qLYuWyJ2cWOdGzRh316vLimCN0QhtCuJsQCy1ncS7LBlbtvx32ox CIaw3xhn2KTsIRLS7sibvvIMxddaYC74L6fEUMfh2w== X-Google-Smtp-Source: APBJJlFNx1G/dTYbHISBVnNCWkJhBHZYFMIwaRoAm1GExuD+Rtxh2jfl+e6y6TyB7XOgI95ZC61O/w== X-Received: by 2002:a05:6e02:1d95:b0:348:8d7c:ea95 with SMTP id h21-20020a056e021d9500b003488d7cea95mr354743ila.22.1690567821870; Fri, 28 Jul 2023 11:10:21 -0700 (PDT) Received: from localhost.localdomain (75-166-135-140.hlrn.qwest.net. [75.166.135.140]) by smtp.gmail.com with ESMTPSA id j17-20020a926e11000000b0034881250ac8sm1304653ilc.28.2023.07.28.11.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 11:10:21 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom de Vries , Tom Tromey Subject: [PATCH] Restore previous sigmask in gdb.block_signals Date: Fri, 28 Jul 2023 12:10:11 -0600 Message-Id: <20230728181011.2651060-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham 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 de Vries found a bug where, sometimes, a SIGCHLD would be delivered to a non-main thread, wreaking havoc. The problem is that gdb.block_signals was unblocking the signals it blocked -- but it was being called from the DAP thread, leading to SIGCHLD being unblocked there. This patch fixes the problem by restoring the previous set of signals instead. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30680 --- gdb/python/lib/gdb/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 98aadb1dfea..b3124369fe8 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -271,11 +271,11 @@ def blocked_signals(): return to_block = {signal.SIGCHLD, signal.SIGINT, signal.SIGALRM, signal.SIGWINCH} - signal.pthread_sigmask(signal.SIG_BLOCK, to_block) + old_mask = signal.pthread_sigmask(signal.SIG_BLOCK, to_block) try: yield None finally: - signal.pthread_sigmask(signal.SIG_UNBLOCK, to_block) + signal.pthread_sigmask(signal.SIG_SETMASK, old_mask) class Thread(threading.Thread): -- 2.40.1