From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30801 invoked by alias); 27 Dec 2018 03:13:45 -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 30738 invoked by uid 89); 27 Dec 2018 03:13:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=H*Ad:D*ubuntu.com, HX-Received:a19, UD:20150623.gappssmtp.com, H*RU:sk:mail-lf X-HELO: mail-lf1-f47.google.com Received: from mail-lf1-f47.google.com (HELO mail-lf1-f47.google.com) (209.85.167.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Dec 2018 03:13:27 +0000 Received: by mail-lf1-f47.google.com with SMTP id f23so11844910lfc.13 for ; Wed, 26 Dec 2018 19:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=4KjlQ0ELGcL2s1b+Zvw/JMxQ/xdcaJi78C3X8JicjQA=; b=IiLBEDaHW9D9+GufDvS/pJTIWNLwriUHp1rFqdk8X/1a6vbhKOh2v9B2kj+wSVmXtt NDFp6g782MCAeu9hXi5kUEe6T8xD8dhC6aUSIV9pK8tK55Tw9GtxIjYUjdWG1UzN5Knn a7hII3KmpWTn02VJNNe0woyRoFnIIqEB37x6F2BDEefEhOvYWc0pT0GHBH1K9koxfES5 nO3/pnvJwBIVG+elsS77/XJXvozfPQeY85kRQ9wx4vDMTfHJMNVJvu76JQqN949y7AzI biEo6r0sEyMgxVh9HEfbNUfRulK288RxvXqJA0rV9wtWMauGOGMy+yOR7QqlnmtIRziK 5Zyw== MIME-Version: 1.0 References: <75551ca3-e964-cdfa-0a65-2f9b1b34fcb7@ubuntu.com> <76c6e133-f842-2ba6-1c26-911633941937@ubuntu.com> In-Reply-To: From: Ian Lance Taylor Date: Thu, 27 Dec 2018 09:42:00 -0000 Message-ID: Subject: Re: [gofrontend-dev] Re: libgo patch committed: Add precise stack scan support To: Cherry Zhang Cc: Matthias Klose , gcc-patches , gofrontend-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2018-12/txt/msg01694.txt.bz2 On Wed, Dec 26, 2018 at 7:39 AM Cherry Zhang wrote: > > Finally I found an ARM machine and was able to build ARM32 gcc on it, and= reproduced the failures. The Go programs aborted, in parse_lsda_header, ca= lled from probestackmaps in the runtime startup. It seems that _Unwind_GetL= anguageSpecificData doesn't return a valid LSDA when called from a callback= from _Unwind_Backtrace. > > Reading the unwinder's source code in libgcc, it seems that a function ma= y have a "predefined" personality function, and in this case an ARM-specifi= c "compact" model is used, which doesn't use the standard LSDA. _Unwind_Get= LanguageSpecificData doesn't distinguish this and simply assumes the "gener= ic" model is used, i.e. not used with a "predefined" personality function. = This works fine if _Unwind_GetLanguageSpecificData is called from a non-pre= defined personality function, but it doesn't work if it is called during _U= nwind_Backtrace. > > The patch below (also CL https://go-review.googlesource.com/c/gofrontend/= +/155758) will fix the problem, by checking which model is used before call= ing _Unwind_GetLanguageSpecificData. > > Alternatively, we could change _Unwind_GetLanguageSpecificData in libgcc = to returning NULL when a predefined personality function is used. > > Let me know what you think. > > Thanks, > Cherry > > diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c > index f4bbfb60..388d7c70 100644 > --- a/libgo/runtime/go-unwind.c > +++ b/libgo/runtime/go-unwind.c > @@ -646,6 +646,17 @@ findstackmaps (struct _Unwind_Context *context, _Unw= ind_Ptr *ip, _Unwind_Ptr *sp > _sleb128_t index; > int size; > > +#ifdef __ARM_EABI_UNWINDER__ > + { > + _Unwind_Control_Block *ucbp; > + ucbp =3D (_Unwind_Control_Block *) _Unwind_GetGR (context, 12); > + if (*ucbp->pr_cache.ehtp & (1u << 31)) > + // The "compact" model is used, with one of the predefined > + // personality functions. It doesn't have standard LSDA. > + return NOTFOUND_OK; > + } > +#endif > + > language_specific_data =3D (const unsigned char *) > _Unwind_GetLanguageSpecificData (context); > Thanks. Committed to mainline. Ian