From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104750 invoked by alias); 28 Dec 2015 19:58:39 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 104341 invoked by uid 89); 28 Dec 2015 19:58:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=symbolic, 246, Hx-languages-length:1694, sk:backtra X-Spam-User: qpsmtpd, 2 recipients X-HELO: torfep02.bell.net Received: from simcoe208srvr.owm.bell.net (HELO torfep02.bell.net) (184.150.200.208) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 28 Dec 2015 19:58:36 +0000 Received: from bell.net torfep02 184.150.200.158 by torfep02.bell.net with ESMTP id <20151228195834.BKXJ24459.torfep02.bell.net@torspm01.bell.net>; Mon, 28 Dec 2015 14:58:34 -0500 Received: from [192.168.2.10] (really [70.53.62.134]) by torspm01.bell.net with ESMTP id <20151228195833.XVZV15009.torspm01.bell.net@[192.168.2.10]>; Mon, 28 Dec 2015 14:58:33 -0500 From: John David Anglin Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: multipart/mixed; boundary=Apple-Mail-15-579111121 Date: Mon, 28 Dec 2015 19:58:00 -0000 Subject: [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux* Cc: fortran@gcc.gnu.org To: GCC Patches Message-Id: X-Opwv-CommTouchExtSvcRefID: str=0001.0A020201.5681946A.0020,ss=1,re=0.000,fgs=0 X-SW-Source: 2015-12/txt/msg00145.txt.bz2 --Apple-Mail-15-579111121 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 663 The hppa*-*-hpux* target does not support __sync builtins. As a result, li= bbacktrace does not support backtraces when threads are active. Instead of always assuming threads are active in libgfortran/runtime/backtr= ace.c, the attached patch uses __gthread_active_p() to determine whether threads are active or = not. In addition, if backtrace_create_state returns NULL, we just return from show_backtrace(= ). This avoids a segmentation fault when threads are active. This fixes the failure of gfortran.dg/backtrace_1.f90 on hpux. Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. Okay for trunk? Dave -- John David Anglin dave.anglin@bell.net --Apple-Mail-15-579111121 Content-Disposition: attachment; filename=backtrace.c.d.2.txt Content-Type: text/plain; name="backtrace.c.d.2.txt" Content-Transfer-Encoding: 7bit Content-length: 1022 2015-12-28 John David Anglin PR libfortran/68744 * runtime/backtrace.c: Include gthr.h. (show_backtrace): Use __gthread_active_p() to determine whether threads are active. Return if lbstate is NULL. Index: runtime/backtrace.c =================================================================== --- runtime/backtrace.c (revision 231814) +++ runtime/backtrace.c (working copy) @@ -24,6 +24,8 @@ #include "libgfortran.h" +#include + #include #include #include @@ -137,8 +139,12 @@ struct backtrace_state *lbstate; struct mystate state = { 0, false, in_signal_handler }; - lbstate = backtrace_create_state (NULL, 1, error_callback, NULL); + lbstate = backtrace_create_state (NULL, __gthread_active_p (), + error_callback, NULL); + if (lbstate == NULL) + return; + if (!BACKTRACE_SUPPORTED || (in_signal_handler && BACKTRACE_USES_MALLOC)) { /* If symbolic backtrace is not supported on this target, or would --Apple-Mail-15-579111121--