From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4982 invoked by alias); 27 May 2014 11:57:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4960 invoked by uid 89); 27 May 2014 11:57:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00,LIKELY_SPAM_BODY,RP_MATCHES_RCVD,SPAM_SUBJECT,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 May 2014 11:57:39 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4RBvc0Y003803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 May 2014 07:57:38 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4RBvapb007322 for ; Tue, 27 May 2014 07:57:37 -0400 From: Pedro Alves To: gcc-patches@gcc.gnu.org Subject: [PATCH 0/3] mangler/demangler dogfooding Date: Tue, 27 May 2014 11:57:00 -0000 Message-Id: <1401191856-27585-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-05/txt/msg02276.txt.bz2 There's been discussion on the GDB lists about demangler crashes bringing down GDB. Such demangler bugs should be fixed, of course. Patch 2 in this series fixes the one that is currently known. But while GDB demangles all symbols in every file it loads, always, in libstdc++, the demangler is only called in error situations, and then only to demangle the few symbols that appear in the backtrace. This means that mangler/demangler bugs can easily escape undetected until much later, when the user is trying to debug the program. So we had a discussion in the gdb lists about whether there is something that could be done to demangler testing to make it more effective in catching bugs that GDB would catch. Ideas in progress so far: - Just throw more symbols at it once in a while. We'd like to try "demangling the world" once in a while. That is, demangle all symbols in a distro. Florian Weimer did this with the ELF symbols in Fedora 20 and rawhide, and didn't get any crashes, which is reassuring. We haven't yet tried extracting and demangling all DWARF symbols, but we'd like to get there too. - Throw pseudo-random symbols at the demangler. That is, make it more robust wrt to invalid input. Gary wrote a fuzzy tester, and it already caught a few crashes. - Teach g++ itself to try to demangle any symbol it generates/mangles ... when checking is enabled in the build. The idea here is validate the mangling/demangling as close as possible to the generator as possible. Patch 3 in this series implements this. This is my favorite approach, as this catches demangler crashes much earlier in the cycle, when building libstdc++ and friends, and when running g++'s testsuite, rather than much later in production when the user is trying to debug the code, or the program tries to generate a backtrace. Both libstdc++ and the testsuite include a good set of tricky symbols to demangle, and the latter naturally includes all sort of random, weird, code full of corner cases. And, I assume g++ maintainers once in a while run WIP g++ through some piles of very complicated C++ code. Patch 2 fixes the demangler crashes I got when running the testsuite with patch 3 installed. And then patch 1 fixes crashes in the demangler debug that I got while I was writing patch 2. Pedro Alves (3): Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined PR other/61321 - demangler crash on casts in template parameters mangler/demangler dogfooding gcc/cp/mangle.c | 30 ++++++++++++++++++++++++ include/demangle.h | 4 ++++ libiberty/cp-demangle.c | 43 ++++++++++++++++++++++++++++------- libiberty/cp-demint.c | 1 + libiberty/testsuite/demangle-expected | 23 +++++++++++++++++++ 5 files changed, 93 insertions(+), 8 deletions(-) -- 1.9.0