* [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux*
@ 2015-12-28 19:58 John David Anglin
2016-01-23 22:40 ` John David Anglin
0 siblings, 1 reply; 3+ messages in thread
From: John David Anglin @ 2015-12-28 19:58 UTC (permalink / raw)
To: GCC Patches; +Cc: fortran
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
The hppa*-*-hpux* target does not support __sync builtins. As a result, libbacktrace does not
support backtraces when threads are active.
Instead of always assuming threads are active in libgfortran/runtime/backtrace.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
[-- Attachment #2: backtrace.c.d.2.txt --]
[-- Type: text/plain, Size: 1022 bytes --]
2015-12-28 John David Anglin <danglin@gcc.gnu.org>
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 <gthr.h>
+
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux*
2015-12-28 19:58 [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux* John David Anglin
@ 2016-01-23 22:40 ` John David Anglin
2016-01-23 23:12 ` Jerry DeLisle
0 siblings, 1 reply; 3+ messages in thread
From: John David Anglin @ 2016-01-23 22:40 UTC (permalink / raw)
To: John David Anglin; +Cc: GCC Patches, fortran
Ping.
On 2015-12-28, at 2:58 PM, John David Anglin wrote:
> The hppa*-*-hpux* target does not support __sync builtins. As a result, libbacktrace does not
> support backtraces when threads are active.
>
> Instead of always assuming threads are active in libgfortran/runtime/backtrace.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
>
>
> <backtrace.c.d.2.txt>
--
John David Anglin dave.anglin@bell.net
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux*
2016-01-23 22:40 ` John David Anglin
@ 2016-01-23 23:12 ` Jerry DeLisle
0 siblings, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2016-01-23 23:12 UTC (permalink / raw)
To: John David Anglin; +Cc: GCC Patches, fortran
On 01/23/2016 02:40 PM, John David Anglin wrote:
> Ping.
>
> On 2015-12-28, at 2:58 PM, John David Anglin wrote:
>
>> The hppa*-*-hpux* target does not support __sync builtins. As a result, libbacktrace does not
>> support backtraces when threads are active.
>>
>> Instead of always assuming threads are active in libgfortran/runtime/backtrace.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?
>>
OK,
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-23 23:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-28 19:58 [PATCH] Fix failure of gfortran.dg/backtrace_1.f90 on hppa*-*-hpux* John David Anglin
2016-01-23 22:40 ` John David Anglin
2016-01-23 23:12 ` Jerry DeLisle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).