From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98229 invoked by alias); 27 Mar 2019 21:34:48 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 98108 invoked by uid 89); 27 Mar 2019 21:34:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1332, H*Ad:U*aph X-HELO: mail-wm1-f49.google.com Received: from mail-wm1-f49.google.com (HELO mail-wm1-f49.google.com) (209.85.128.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Mar 2019 21:34:46 +0000 Received: by mail-wm1-f49.google.com with SMTP id y197so1679970wmd.0 for ; Wed, 27 Mar 2019 14:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JelvwtGVLVfCFOXG/h0IgSEO2GeLNlWuxG8DVYuAOpQ=; b=E72dDL/+fBUQCFaPap1s9D29Tm2kEHf52SZ88fu7r2JMMV9M2jzDiNq48r5L0w+Wl7 pII5QbmLMtz8CXje9bylYrp6sQCCLGtoNdPMRcHVIVAw+P6IxCJluFHqE5gucduXFlpY Q/Ba2sehhU8f24aN41mgiss4H9x0u9goBKQFOj8M2NzdinP3ViDpkZUrYOqtekWoDURZ Bg3HQ6e2tHidwHHdcP2qTHpZQwoDbfMOgyALZEhbwbRIe0fQziYAl9xr2vYSXKBFnJJW KTJZRfNQz665002HVEfF2YtxooDf7JVcsLkhFX46iAinRYKarRzNK4CgEi9pIldkV0+A u9HQ== MIME-Version: 1.0 References: <1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org> <877ecuikq9.fsf@mid.deneb.enyo.de> <835d09ce-752a-c0f7-e5cf-210e855df2ab@jguk.org> <87ef6vkq8a.fsf@mid.deneb.enyo.de> <95ff2a72-47fb-5cc3-5852-08517e3ce76e@redhat.com> <87bm1yho61.fsf@mid.deneb.enyo.de> In-Reply-To: From: Jonathan Wakely Date: Wed, 27 Mar 2019 23:43:00 -0000 Message-ID: Subject: Re: Recursive SIGSEGV question To: Jonny Grant Cc: Florian Weimer , Andrew Haley , Xi Ruoyao , gcc-help Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00196.txt.bz2 On Wed, 27 Mar 2019 at 21:27, Jonny Grant wrote: > Hi! > > Thank you for your reply and input. > > Maybe GCC's "libbacktrace" module could be used? > > I was wondering if -fsanitize=address would output a backtrace for the > C++ exception, but it doesn't seem to. Also it actually prevents the > core being dumped - that's probably not intended? > > Compile without Sanitizer, and it does dump the core to a file at least! > > $ export UBSAN_OPTIONS=print_stacktrace=1 This is a UBsan option. > // g++-8 -fsanitize=address -Wall -o exception exception.cpp But you're not using UBsan. > #include > int main() > { > std::vector v; > return v.at(0); > } > > > $ ./exception > terminate called after throwing an instance of 'std::out_of_range' > what(): vector::_M_range_check: __n (which is 0) >= this->size() > (which is 0) > Aborted There's no undefined behaviour or memory corruption here, so it's not surprising that UBsan and Asan don't print anything. If you want a stack trace for exceptions that terminate the process then you could install a custom terminate handler which does that. Libstdc++'s default terminate handler just prints the message above, which includes the type of the exception and if it's a type derived from std::exception, the what() string stored in it.