Message ID | 046071702889c1a0bb4fe33df605e865b5df571c.camel@espressif.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3EED03858439 for <patchwork@sourceware.org>; Wed, 9 Nov 2022 19:43:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EED03858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668022988; bh=+2/uKbwOYoliiAHDse0ggKh3s8gnF38dmKTGtQxjLVs=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LsH3nHIJ+WWwHEnblAj4LnGvkyRSnqpDJ7i0sB32rX3eakp6CXPtAY4E07zioJJfZ Hj7A5w/aJK5zh/MGdhWPZI+BxgaD6kk0YrYQvey3RM/hswyGHv8ysd4VasfPZ3AYPz QWB+XAZ84fcGzZI6F97ulYoYFGaqo4xtie1JR03Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2132.outbound.protection.outlook.com [40.107.255.132]) by sourceware.org (Postfix) with ESMTPS id 138353858D35 for <gdb-patches@sourceware.org>; Wed, 9 Nov 2022 19:42:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 138353858D35 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCwCOBIIKpDiO3J/Ke8OYn+cbCHKbxPSC3/Agx/aWP5oPSD5mkhbM8sgVj/uF66VA6RuXdZmLRVzaBe9SH5solT8/vi+SyjWvIWY7H82pYYNBiyJdygsE8rYSnqNaqXJeAuO5AwjnPrJuDbW5zoEt0PZhet56iBCDb9ayehhhiPk8PkqFlJTL4UNas46mnJf/7GUdXQaLCNbfPFDdH45yvJ/bPLtft3A1wXa1nCkzh/cMyxQ9GEr++QTiwYkLIAakvMGcfbVsKvyLMXPUUmZ58HbIVaux91f5Wf+7wSaFopjoM2j1O0g4yYkASOPYIb4cfhsvDUCJlkAu0TOS4nvBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+2/uKbwOYoliiAHDse0ggKh3s8gnF38dmKTGtQxjLVs=; b=NA99ALptJfOW91PdiypgLYsk1/4cBFOjKDaMfjG9DQlGuWHA9NNID46VNCvGCfFJiMRGgLZ5qWhC9I596gSypfKfGQ0C8RQokwDB5FCrLZ5KCPvkmAF1pOO3YbCkmRYv6Hwx7rQ3MDk90ldbPt4IxbjSb5iIPq+CkQqgj95CayCcBJUe5Z3lMFOFyZuVRNTZaK+nSJhqNuPtFfyF9Ak2hmpVDvLLpaa8hHPVQJkA7gV8NToC6myiuWGDgY6Wgrc9N+/TiDmooZBLANvR7tcQx5jc3yzy4lra2NFxpDBtIhlmYwiq20KFb8ZemamXfzhXf0ap0tqM1MV4ifxXur5Ydw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=espressif.com; dmarc=pass action=none header.from=espressif.com; dkim=pass header.d=espressif.com; arc=none Received: from TYZPR04MB5736.apcprd04.prod.outlook.com (2603:1096:400:1fa::7) by TYZPR04MB6666.apcprd04.prod.outlook.com (2603:1096:400:337::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12; Wed, 9 Nov 2022 19:42:37 +0000 Received: from TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::e64d:5c85:a83c:5898]) by TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::e64d:5c85:a83c:5898%5]) with mapi id 15.20.5813.012; Wed, 9 Nov 2022 19:42:37 +0000 To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org> CC: Alexey Gerenkov <alexey.gerenkov@espressif.com>, Anton Maklakov <anton.maklakov@espressif.com>, Ivan Grokhotkov <ivan@espressif.com> Subject: [PATCH] gdb/python: initialize Python without signal handlers Thread-Topic: [PATCH] gdb/python: initialize Python without signal handlers Thread-Index: AQHY9HNr8FVZ9UOfikyBKh+VKRz9Pw== Date: Wed, 9 Nov 2022 19:42:36 +0000 Message-ID: <046071702889c1a0bb4fe33df605e865b5df571c.camel@espressif.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR04MB5736:EE_|TYZPR04MB6666:EE_ x-ms-office365-filtering-correlation-id: 8d4c4853-1090-44e7-8a5f-08dac28a8dfa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ms1nmj3pT8KRe3/52jvx1tM4i//lb/QTMVt7CTtLwYcaXVK17wHmZfr75jUx0573+vcSzEDY4YF2+7VAmqqxgAnYXx5FFED1yKQMVvAYFl+87FGIvmJKTU9/bJQkYioimtZlBLxm1+9XfauNle0dDpkb7HvaDYf1xTlSXU3IAyXQTOg0Ud1X0RE/6RBmzTLmsV8YQCs13UoVA4hlE90z1BSUDFs0F46pqyFBqXFSHyCVKNUcXgWs/yMJfJ5yvJibOIyomD/PWQkbQ0ZRh76LBDcnw2llsCKskYn8PLkhfCe7/3Y2Dx9RclZKQwKp/W27DzpzAOJagyawhPaOKMpdNeTXbRCaMrIBD4H0cj9UjvZiMroSVZe/AEVfuQGIL2VbTHxkoov/U3T2m3gKHTE2fnrGhnFtWc7SmfXhxM+Rh8Gx+eOZEVQFGtjxkctu3ErT8Yta+QEeO3dCEC/P00e2bKtbsNyU0QbSFIsWWiqo/WBRah7I9W4/hvKSKiSuQ76+GsF1JeBVkOxGvNumL++rtMO1IhmxxsEI//GLMAS8o4XeFkChdQ5VAcKeKn8HYV6E94FLPj8OqxEmRie69x84aiuETJKOaKZBgPv7Bp6avTavF3jAY1WFzREtnovcNzt77y0MTsI27hWd+MjyXK39z8UU/7hf+YfuIPNEy+9L1Ri7OyMSoelW9DnAupSDCFE0enCInojDlHibUtoDnj8XuYXI4nEWiDkNcCgvK50oNiYNNCFpm30ZAoVnqF5hY5ZyrrJYwmZvh5XfVvYIEcti/g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB5736.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(366004)(396003)(39840400004)(136003)(346002)(451199015)(41300700001)(8676002)(4326008)(64756008)(66446008)(66946007)(76116006)(66476007)(66556008)(107886003)(91956017)(5660300002)(6512007)(83380400001)(6916009)(54906003)(2906002)(26005)(86362001)(36756003)(38100700002)(6486002)(2616005)(478600001)(6506007)(8936002)(44832011)(316002)(71200400001)(122000001)(38070700005)(186003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?ZrR83q7ZFv7BFHnVN+kzH7fKIn4m?= =?utf-8?q?mXZdg1u75ak93nbXsUQDcvUeRT5BNvvrK7BRioYMkdI4RJ+Xr2DXmVTESvz+g6TPa?= =?utf-8?q?kNvZljUQgKegJgTYiQ9ln3XAPvn7xTC4IpPtmhYLmci7I71R9C/uqA9zWSwnMfXrW?= =?utf-8?q?pLIKoXcLBlXnQPpfyB6huKaN6yKp38cY26+lJ+UnQoVvq/zmX3iWEHPwGbl1AeoPh?= =?utf-8?q?07LFj6K3wY3Kl37vuBgM70WbXtYD4hcRRd8zQ5vRCvr15Wy0+kN1ChK+am5KaLoeV?= =?utf-8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tA1InMlMB8pjEk6rIkUbI1NB2twAR94qy9lqPSkxbah/JfZfyHkpYbgblvvQb?= =?utf-8?q?ea1Lipxwz1rclAwiZ1yF7mV3AIJbsoUfq52GJSJdjS16EyRAYl7UUWG+XwxKzKHOB?= =?utf-8?q?cJdKOZa3DvjJMwPTyhupU7b8GDiorO9iPG4kQVJVksyZkRkDw1yVAfnLn6DuLPt/n?= =?utf-8?q?F4P0Oj2qelpSDLTRQq0XPREgL+vjmhOtDw3QdQ/fwe3Fv7r/sCkg1D66gyVJK2pDh?= =?utf-8?q?c48FNrn25bQh7pGJ9d2/uWCJetMMaozIqWOW4PKqpaZahfWD6XKwj4emu8AF3onzz?= =?utf-8?q?VIEe/shd3nFsTNNoZWJAHftIPTwnZPSUHqYsQfDNsoBuhdO5kL2WwvUGsHdSco9Pc?= =?utf-8?q?X4/0LhC/SkGw4z56rhZ7FDmwxvKGRUjUP3lSajp3tdXzQb3c2Qkv9hk=3D?= Content-Type: text/plain; charset="utf-8" Content-ID: <55A55CA6F1C755488942EA0C3CC4D8D1@apcprd04.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: espressif.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB5736.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d4c4853-1090-44e7-8a5f-08dac28a8dfa X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2022 19:42:36.9160 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5faf27fd-3557-4294-9545-8ea74a409f39 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vLeIYQc4ZYHf+XAxrD0D/VjJepxM1vQREnG3V/uygRlLSvCt3pXGhptnuvM6BdGjjJrlvoaUhOP6COC7Z0/tSQZGaeGktBTIKlW467YS66o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6666 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Alexey Lapshin via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Alexey Lapshin <alexey.lapshin@espressif.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdb/python: initialize Python without signal handlers
|
|
Commit Message
Alexey Lapshin
Nov. 9, 2022, 7:42 p.m. UTC
Fix embedded Python initialization. Installing signal handlers on Windows GDB builds might lead to issues --- gdb/python/python.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.34.1
Comments
>>>>> "Alexey" == Alexey Lapshin via Gdb-patches <gdb-patches@sourceware.org> writes:
Alexey> Fix embedded Python initialization.
Alexey> Installing signal handlers on Windows GDB builds might lead to issues
Could you say what these issues are and why it's desirable to make this
change for all hosts?
Tom
> > Could you say what these issues are and why it's desirable to make > this > change for all hosts? The issues related to signal handlings. For Windows builds CTRL+C does not work. Because it handles by Pyhton, not a GDB. I don't know why it does not happen on Linux builds, but I believe that signal handlers must not be set. Also, documentation (https://sourceware.org/gdb/onlinedocs/gdb/Basic-Python.html) says: > If your program changes the handling of these signals, GDB will most likely stop working correctly. So, there is no reason to set default Python signal handlings that could differ from version to version And it's better to handle all signals in GDB itself, not in third-party libraries Regards, Alexey
>> Could you say what these issues are and why it's desirable to make >> this change for all hosts? Alexey> The issues related to signal handlings. For Windows builds CTRL+C does Alexey> not work. We fixed this a different way. Alexey> So, there is no reason to set default Python signal handlings Alexey> that could differ from version to version And it's better to Alexey> handle all signals in GDB itself, not in third-party libraries This makes sense but I wonder if there are other impacts from this change that we wouldn't want. For example, if it affects Python scripts running in gdb. Tom
> We fixed this a different way. Could you please give a commit hash? > For example, if it affects Python scripts I don't think that will break anything, because Python only sets SIGPIPE, SIGXFZ, SIGXFSZ signals to ignore (https://github.com/python/cpython/blob/0e081a089ec969c9a34f5ff25886205616ef4dd3/Modules/signalmodule.c#L1910-L1918 ). And sets SIGINT signal handler, which is not using. Because POSIX standard declares that only one signal handler could be set for a signal. We know that Python SIGINT-handler is not using in GDB for linux because we could not stop debugging applications otherwise. I just wanted to init Python properly. See also a comment in Python source code. It also is not strictly related to this patch, but could be interesting for you. https://github.com/python/cpython/blob/135ec7cefbaffd516b77362ad2b2ad1025af462e/Python/pythonrun.c#L1680-L1687 Regards, Alexey
diff --git a/gdb/python/python.c b/gdb/python/python.c index 29f2010ee8e..833eedd35f9 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -2050,7 +2050,7 @@ do_start_initialization () remain alive for the duration of the program's execution, so it is not freed after this call. */ Py_SetProgramName (progname_copy); - Py_Initialize (); + Py_InitializeEx (0); #else PyConfig config; @@ -2062,6 +2062,7 @@ do_start_initialization () config.write_bytecode = python_write_bytecode (); config.use_environment = !python_ignore_environment; + config.install_signal_handlers = 0; status = PyConfig_Read (&config); if (PyStatus_Exception (status)) @@ -2075,7 +2076,7 @@ do_start_initialization () return false; #endif #else - Py_Initialize (); + Py_InitializeEx (0); #endif #if PY_VERSION_HEX < 0x03090000