From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yj/kHBiFMWrLmwoAWB0awg (envelope-from ) for ; Tue, 16 Jun 2026 13:17:12 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=LPVBkn0p; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 654331E070; Tue, 16 Jun 2026 13:17:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D16C41E070 for ; Tue, 16 Jun 2026 13:17:10 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2878C48F6698 for ; Tue, 16 Jun 2026 17:17:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2878C48F6698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1781630229; bh=LVyrdQXQWCiRO1A2I3ovJHa+w93cib1QpDmpb7gtVq0=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LPVBkn0pbH2c/sjwOgeegs1G0cBg/snR6OjDkSn4kLqAuHV7aS/B4s1of597/VfTN rYEAmWt1UznU2uy3tvqUP0xyHr18jzlKe1D4ouvd1J9dj+MBFi9pOCJzKIn7Ci8/18 WfzVYyNX3+rhbIf15pjgz+9qsk7y2yQBajeJ5HPQ= Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11012004.outbound.protection.outlook.com [52.101.66.4]) by sourceware.org (Postfix) with ESMTPS id 8904848FED86 for ; Tue, 16 Jun 2026 17:16:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8904848FED86 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8904848FED86 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1781630190; cv=pass; b=fnma877ApqYZxtXv2zhLrIEa+sLXil/DaBI2hiiXZktVf6hl4xbpXIkzJ0XSzL8oDiyzfICUhFI6amsSb1d/xsk9q13F1GBtn1mAwMMuDBcD+isjMXAg4h5Vrord2NvHAf8Rx71NkLRSPhxCXfE4kr4QnYn8u91C9HusS+ZzXpw= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1781630190; c=relaxed/simple; bh=jBilv2xBRjsagpyJdYegnSpzXwyDGq+KTgeaZWcZJkw=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=f1z6fa7qpbJ5evTN0wyf0EDrfDVXRuLMhva2bCgdLHk+7PxGhawTzl9tHS0/CceqKzGNjUqbZ3O+EXwzmH8tqhAiunsvywBCOA3mjAbn+9fEHZ9AS4gviZmtW4tpmu1CEW1OqdmHn0qZSbNrZLQRFGAXvg/UWfcZ1XKhqmyoxF4= ARC-Authentication-Results: i=3; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=azrTHq+F; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=azrTHq+F DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8904848FED86 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=mC8h8RFjQSNUh3AxZPjjM9XrVLJcBd2U4rU6n2g7LJ6VRLlLU1SunVcr7930GNSbnj2rYpA7ckUwO+iEL/S3Ddsg1BXGQIbVNPp+stWJ2UbePRtuUyk/VVvITZABv+IjMRbbfUGsvDpjqIioqJKYifevCxrqWl8QTslxXgmeC+OvNkuU2arc79kSx7AZYFml06v7YuVNhkzJbLkRjwJFgyfXLa+CKUbCulN2OKqCQ6p9fyFnbl4a5eMe1aPmhOqbcXYXwU9r2AQIem2zSWapi5Qv4K/HnisPOq6mpLY4HJZ6fiW0t7V02vLUb6h1NbYNNZ3kEEX3LdYNP7epNGaATQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LVyrdQXQWCiRO1A2I3ovJHa+w93cib1QpDmpb7gtVq0=; b=j4IjEM6GGKVEAyfjN/DD3mM3Xl22Xmh5xysyin2D+PWze3wmNn1p2v7yfK8DD1G29qYpJPKBK/fFK5/FddyrhLPOnLOOD8jzEw5eFak9V/Nqm22nHOAoK383p1CMgvBPcO/0bkoOPJ3MgmMzDWtGc/dyo9+H0nWrMUcp1hqeqV7j8g4B2YrIM0N5x/EFM79Kh3bqVW61c5+8q9X8KNebCzohbCCivpJzUkhSs2CoamzrGhO1Vr/9x8yWEKCTf1wUlOH+pYWu0wIaKvtCrbR8r/seHs5lWda2r+F9cHeRMR375K8j7TCfljhsyBCQyYlOPxaYin2REs8pNm6YDGT5Pw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=redhat.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from CWLP123CA0079.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::19) by AM8PR08MB6371.eurprd08.prod.outlook.com (2603:10a6:20b:363::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.18; Tue, 16 Jun 2026 17:16:22 +0000 Received: from AM3PEPF0000A794.eurprd04.prod.outlook.com (2603:10a6:401:5b:cafe::b6) by CWLP123CA0079.outlook.office365.com (2603:10a6:401:5b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.113.18 via Frontend Transport; Tue, 16 Jun 2026 17:16:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by AM3PEPF0000A794.mail.protection.outlook.com (10.167.16.123) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.139.8 via Frontend Transport; Tue, 16 Jun 2026 17:16:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I2He1p4nY8Zg2MHeLKUUBFkgiKh/XHXkZWRfRV14AsUVx1OSnfCuy5VzU35Hf3LxfuvC63TKSTz3e6xhppiMpMno8IXPbESVRoIoA1kV8ye0BspRBkgX+APVZtUncdyJvwsoxAa5PIXEvDzbgByWBb7SCMnxmxoeXJLxxYzeOee7JNr1DzrBK1cAJsdhNHZXpQndkjD2XoTFhvqn1ftF7JsC5LcGw0+T3PnN6QwyaN//Y3yhCAJzJbj3Wa2ifn9wTYUo2gNI6/ndMbuNik2s6BhN/7nkpdnkV3Dt58HOri3ml7c29P9PIC6HvMhjIbV633O5hEqo05mAIb/Z8npFBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LVyrdQXQWCiRO1A2I3ovJHa+w93cib1QpDmpb7gtVq0=; b=n9Tg3mOESRnRR55B4EDbtu1Jr6HrU5wln17iZHHRlio6QoVlwocve2Ml15y2lrbV1l8SQr6gRrKb++B8c1g3VCR53ZSt/xTbUV3nutaFnjwoLB4c5I9BBFomowvIgEGCxXIyrrhIjg5gM40vrS3jGx/EDkefCX0jpechGdTqU8A6SPAvXJOVRjiAjmOSFMScmBGwB/C95JCvorZSDbmN9So0T7ilGQynUtwWj0OxTMc8kl0r4n2/sThj8nzOd0jPBxV83b2WAejnP0Mn8m0VUiLiyP0DokT1ssui4sCheTiUGQ/T5PI7UkJp9ArNnX1BKtRYDnkdcWj0POtdbmMNRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DU0PR08MB8663.eurprd08.prod.outlook.com (2603:10a6:10:401::6) by AS2PR08MB8671.eurprd08.prod.outlook.com (2603:10a6:20b:55e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.18; Tue, 16 Jun 2026 17:15:18 +0000 Received: from DU0PR08MB8663.eurprd08.prod.outlook.com ([fe80::f957:cec9:ec8d:7968]) by DU0PR08MB8663.eurprd08.prod.outlook.com ([fe80::f957:cec9:ec8d:7968%2]) with mapi id 15.21.0113.015; Tue, 16 Jun 2026 17:15:18 +0000 Message-ID: Date: Tue, 16 Jun 2026 18:15:17 +0100 User-Agent: Mozilla Thunderbird Subject: Re: RFC: prototype of C extensions using the Python limited API To: Andrew Burgess , Tom Tromey Cc: gdb@sourceware.org References: <21479c1d-3a9a-4ae2-bc1a-5dc19871f275@arm.com> <87v7bqpeab.fsf@redhat.com> Content-Language: en-US In-Reply-To: <87v7bqpeab.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PA7P264CA0193.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:376::9) To DU0PR08MB8663.eurprd08.prod.outlook.com (2603:10a6:10:401::6) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DU0PR08MB8663:EE_|AS2PR08MB8671:EE_|AM3PEPF0000A794:EE_|AM8PR08MB6371:EE_ X-MS-Office365-Filtering-Correlation-Id: 218ec169-0d02-49a9-996c-08decbcafd2f x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|1800799024|366016|23010399003|3023799007|22082099003|18002099003|4143699003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info-Original: 51PFWt6HJvWTr4vMcC1hK5zzNO6C60cqse1/dLkhWg+8aLzshyxSi/0Zt5vLxyGFbCqUF2Lkt7c0/R9FeU1i7k2WuMLdzc9GuPlXwBs0zOvWgGiusNKOe6F4PQO0l5+ajyCeLGrJhfv+JfQuaFK803ot58h4DRargGCqrNVH7UUwLSF7brm9msOF1k3EjSnlqiTaTKGGp1SX1829iPdgia5oAE1AO+wS92ss4hqr6GlF0ZlHsLVayeRtkQf1EQtpcugH4v4EMAqXgw4RqBtUt46Q4JKVJX30Qi+D54QAga3fn9boOMB6qzYPvuSgWrUW3AuC0kLVgttAEycoRHr0UPFICdVhKNeXX6sfkJzOwpxUjCkJq7Wx6Wq/XzisHbt6kxBDUcZ+bpR7cBWf8z2R7iivfkGwhn3uPoXv1sfOL3FRhtobeGR7T6IAwQmvAPdhWQXGsbSWivCxRKZXgB7hZf4y1sj0bAW4Nn4V4ztMLVtOBy4p5AW4GoVcfso6FTrCJ0RAPVk5K75jXiXpCEcfSqZMQjWGmn0jQYGTh0wjzAP5TupO5Zf9nNsVuL1yoJ26Fkkl+oREqYqbd7WQzSQHKEY68xNo0G06AxhtrNttDjo+kLmsTHg6Ev7xeDk/c4LJC+9ouX8M/1r1BV6Clgzk1CV+Yy08otTD53pZW/Aux4tCoQjTl0NRm+Cit0ENXGIa X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR08MB8663.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(23010399003)(3023799007)(22082099003)(18002099003)(4143699003)(56012099006)(11063799006); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: q4gwUUjwUeXe6wWJF0vSlpH790ILw7W4/CgND8hFASLlSHmWHUchT/Rx4vbwWCFWXr6WjKDzi49anAd6/wpfOMKyRjSp0GvxJ7yoGZBjRtRWsXo3VXoAcjoF5QHO6BhMtEEj+IUKDQkiBb8q1rkt0hzGhyLHQTvY5/ee1mQ/iNfMRXUfR3+/oWESAJtMdXFqE9XqDovBoWpJpnPW3sFwrcgn8G7NeTjgJzr8PEOJZ0k7fWYBpX0EhvvsjkWO5C1uz/sbb2deNY4R74DEjiTMV4YIZp/xY/JoOsPjYsy3XoO/PnNqqr0/fX2KoaocK73sWFatmK/GlxeFQiTvGU+E6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8671 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF0000A794.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 78093ab0-ddd2-48b3-e51a-08decbcad6f7 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|30052699003|23010399003|35042699022|14060799003|1800799024|36860700016|11063799006|56012099006|22082099003|18002099003|3023799007|4143699003; X-Microsoft-Antispam-Message-Info: Og85sLv6MYNYCJg82G3x6UV5LXy15mJSVdR9ezZGDz9nE/fUzEoCjYwEyLVBWYHZJY6J4Y5jQHdOkRu7C1+hovAtXVV/HsdLaAmxgITAW3O9X4+0wDjpbRis1QPvgGbVRR2byom68raZh/ZA2RN0QNLKx7VmwpAOrkee5N81Te07o/yN8VZ2Gj9uOEyuK+oDOnxsypb4c50NtD79xgfuzNgiFbAT2iZr61nQ+R/C4njtq7K6c0ncXdOThPnbwjcurcfftWOPskWWjnhDrto9vxvTxow3bUEEubbDTVgyEmRu4W1L01Ao68CHGdto9Iv4cDX0Yy5nfeToSKL0V9Xx7RA8bE+7yFm5uuhu1v3ylIe3yfy1mpc9eh1VsgHbXI93EA3NzM2zdGAdcRAMd4Iba0cRU6bkud95GBoKPsPeDMtHyEadqxVjSsMxMUbGVYV9nQY762+Z4S+TzGPkvWYtUCvvvIhu6+w2Jsid/YZaC02qe7U+jjwzHrfo4qYGxYUQmSXNpAzVQlpjLWNWDYyKVVreJRPBBDlTNq2Oi173T5NPdo6bwJaClyJzOzcMd6agkgeY0F7ii6BWXY6/P3JNY5RHVqsFkxlR4pnuBAhPJabQp/DuhjbJ9He37lWS4KhGhYTGDgC3tQsPyt5H4LtxDPvaBVsuh3lMmZMBxPP5ArFkveEuNXlVlFsgE6jJdvQ4zO/inrE8tI0USEuCs08Oa7/jO3kNui0zMnRuXiXDOi4= X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(30052699003)(23010399003)(35042699022)(14060799003)(1800799024)(36860700016)(11063799006)(56012099006)(22082099003)(18002099003)(3023799007)(4143699003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mzs7U70lTifzJ+uEX4FtjycKEIRHojn/PtZQzc2WFgDeDZTqJ3dk8a5Aaa5nPG1V5xne+6BD9Q+Oxr8euTBBOnULlebLLDax+PXIM7FMO3IwQ8Lzva4KpqziVw7l0FgMY9nytlwGMk1/rqvwgkL9FnvaGh1eptIKnp95mnvUUXej0EXHQl5EvuhtPadTlDTvTyeCkKDHVlKKzf9TiBUQyC2ijSbt7h7vysAT/j3Isx8We4IR1oK0FoDqhx7mjdAHTaeIikdcGHDvvKiGv4MEKcHzufffMCN53rYsNBdQtjoTc2sr3Z1RjKqjpGvWEbQiZQ48h/uMiwznpwj7sq/sgOvr0gc0Vfh7gJlr/v1PKQyOCqAB0EtDsTY6iPqydwuK0eA0mXIR6JMAzdbsqiwkFOv3F+JGh52pcEp+GjBYS2KDJ8v9GgrnqejVWJG8N3WC X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2026 17:16:22.3877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 218ec169-0d02-49a9-996c-08decbcafd2f X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF0000A794.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6371 X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Matthieu Longo via Gdb Reply-To: Matthieu Longo Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" On 10/06/2026 17:10, Andrew Burgess wrote: > Matthieu Longo writes: > >> On 01/06/2026 11:10, Matthieu Longo via Gdb wrote: >>> On 28/05/2026 17:31, Matthieu Longo via Gdb wrote: >>>> On 28/05/2026 17:24, Matthieu Longo via Gdb wrote: >>>>> Hi Tom, >>>>> >>>>> As I previously told you (at least, I believe so but I am not 100% sure), I finished migrating all >>>>> the Python C extensions some time ago. I had discovered some issues with a case of inheritance >>>>> causing unexpected crashes. >>>>> To facilitate the debugging, I decided to implement a prototype outside of GDB, and managed to make >>>>> it work. I finally got the prototype reviewed by Victor Stinner, a Python core developer, to double- >>>>> check whether my design was working as expected. >>>>> >>>>> Please find attached my last iteration. I also provided an archive which should be more convenient >>>>> for you if you want to compile and test it. >>>>> >>>>> Could you please review it so that we validate this new approach before I migrate all my previous >>>>> patches to it ? >>>>> >>>>> PS: >>>>> - a README is provided with all the needed instruction inside. >>>>> - this patch contains code from outside GDB's repository, and should not be merged inside GDB's >>>>> repository. >>>>> >>>>> Regards, >>>>> Matthieu >>>> >>>> With the archive, hopefully not inlined. >>> >>> Hi Tom, >>> >>> Any chance for you to have a look at this in the next two weeks ? >>> >>> Matthieu >> >> Ping. >> Adding Andrew too in the loop. > > Would it be possible to give a brief explanation for what this is all > about? When reviewing something I usually start by reading the > description and then check the code matches what was written, but your > text doesn't really help me ... I suspect there's some back story that > I'm missing, but it would be neat if that could all be summarised, or at > least links to it added, here. > > Thanks, > Andrew > I apologize for the lack of clarity. This is a prototype proposing an approach to migrate the Python C extensions to the limited API. I already started the work a long time ago, but had some memory issues (leaks and crashes due to double calls to destructors in the inheritance cases). I used this prototype to refine the interface, and discuss the issues with Victor Stinner, a CPython core maintainer working on the C API. This versions of the prototype is now be free from leaks and crashes. You can test this on your side by running the example containing different cases (inside pydbg.cpp). The README provides the instruction to build and run the example. Before I apply this approach to all the 40+ files in GDB, I would like to discuss it with GDB maintainers. The prototype is organized as follows: - include/ - py-ref.hpp: copied from GDB. Addition of a clear() method in gdbpy_ref_policy. - py-obj-dict.hpp: I decided to abandon gdbpy_dict_wrapper because the inheritance was causing issues, and opted for a new class, gdbpy_dict_helpers, with logic related to the dict management gathered in static methods. - py-obj-type.hpp: + new convenient wrappers for a PyTypeObject: gdbpy_object_type_ref, gdbpy_object_type_bref and gdbpy_py_obj_type_bref. + gdbpy_heap_type: generic logic for dynamically-allocated types (tp_traverse, tp_clear, tp_dealloc) + auto_gc_track: this class allows to enforce that PyObject_GC_Track() is always called when allocating a object manually. See example in src/ObjWithAlloc.cpp - gdb_ref_ptr.hpp: copied from GDB. Addition of a clear() method. - gdb-others.hpp, python-traits.hpp: some boiler plates copied from GDB. You can ignore the content. - python-internal.hpp: the new gdbpy_type_initialize() used to instantiate and register in the module the Python types. - src/ - py-obj-type.cpp, gdb-others.cpp: boiler plates already in GDB. You can ignore the content. - python-internal.cpp: code for gdbpy_type_initialize - my_py_module.hpp, my_py_module.cpp: declaration of the module and classes A, B and ObjWithAlloc. - A.cpp, B.cpp: examples with inheritance. - ObjWithAlloc.cpp: example with a cycle and manually-allocated object via PyObject_GC_New - CMakeLists.txt: cmake file to build the project. - pydbg.cpp: example containing the different use cases. - README I don't expect a thorough review of all the code, but a validation of the approach. Matthieu