From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 858AB3870842 for ; Thu, 28 May 2020 13:37:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 858AB3870842 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-igQ7g9zEOLCpVIbP3bTSwA-1; Thu, 28 May 2020 09:37:26 -0400 X-MC-Unique: igQ7g9zEOLCpVIbP3bTSwA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5F0C460 for ; Thu, 28 May 2020 13:37:25 +0000 (UTC) Received: from cascais.Home (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 635DB5D9F5 for ; Thu, 28 May 2020 13:37:25 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/1] Fix GDB crash due to infinite recursion in typedef substitution Date: Thu, 28 May 2020 14:37:23 +0100 Message-Id: <20200528133724.24634-1-palves@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 28 May 2020 13:37:33 -0000 This fixes the bug exposed by the "gdb: Remove C++ symbol aliases from completion list" commit. See here for the original investigation and discussions: https://sourceware.org/pipermail/gdb-patches/2020-May/168972.html In a nutshell, the bug is that if you do (gdb) b gdb::option::bool[TAB] while debugging GDB itself, then the top GDB crashes with infinite recursion within the replace_typedefs machinery. The bug was exposed with completion because when doing completion, GDB now calls cp_canonicalize_string_no_typedefs for every symbol that matches. However, the recursion bug is also reproducible if you just set a breakpoint at any of the "bad" symbols too without completion. I.e., "b $bad_symbol[ENTER]". The log in the commit itself is described in terms of the added testcase, not of the GDB internals. In GDB's case, the recursion happens when you set a breakpoint in a symbol that includes a templated named boolean_option_def: gdb::option::boolean_option_def::.... because we have typedefs named boolean_option_def in the global namespace in the program. Here, in stack.c for example: using boolean_option_def = gdb::option::boolean_option_def; Pedro Alves (1): replace_typedefs: handle templates in namespaces gdb/cp-support.c | 71 +++++++++++- .../cp-replace-typedefs-ns-template.cc | 116 +++++++++++++++++++ .../cp-replace-typedefs-ns-template.exp | 127 +++++++++++++++++++++ 3 files changed, 310 insertions(+), 4 deletions(-) create mode 100644 gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.cc create mode 100644 gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp base-commit: 636edd0018b72d67ee224e868fb277a658e9b984 -- 2.14.5