* [Bug libfortran/25377] libgfortran/io/transfer.c:2159 unlock_unit causes segfault
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
@ 2005-12-13 13:10 ` jakub at gcc dot gnu dot org
2005-12-13 16:13 ` jb at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-12-13 13:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jakub at gcc dot gnu dot org 2005-12-13 13:10 -------
Can you attach a testcase?
The gdb session doesn't really provide any useful info.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/25377] libgfortran/io/transfer.c:2159 unlock_unit causes segfault
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
2005-12-13 13:10 ` [Bug libfortran/25377] " jakub at gcc dot gnu dot org
@ 2005-12-13 16:13 ` jb at gcc dot gnu dot org
2006-01-29 17:42 ` [Bug middle-end/25377] [4.2 Regression] weak_ref sibcalled with -fPIC pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu dot org @ 2005-12-13 16:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jb at gcc dot gnu dot org 2005-12-13 16:13 -------
Unfortunately the goto blas library where I noticed this error is not free
software. But here is a simple testcase that shows the same problem.
File hello.c:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 2
void *PrintHello(void *threadid)
{
printf("\n%d: Hello World!\n", threadid);
pthread_exit(NULL);
}
void fhellomt_ ()
{
pthread_t threads[NUM_THREADS];
pthread_attr_t attr;
int rc, t, status;
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);
for(t=0; t<NUM_THREADS; t++){
printf("Creating thread %d\n", t);
rc = pthread_create(&threads[t], &attr, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
pthread_attr_destroy (&attr);
for(t=0; t<NUM_THREADS; t++)
{
rc = pthread_join(threads[t], (void **)&status);
if (rc)
{
printf("ERROR; return code from pthread_join() is %d\n", rc);
exit(-1);
}
printf("Completed join with thread %d status= %d\n",t, status);
}
}
File fpthello.f90:
! Pthreads hello world
program fpthello
implicit none
call fhellomt ()
print *, 'done'
end program fpthello
Compiled with:
gcc -c hello.c
gfortran fpthello.f90 hello.o -lpthread
Running it produces:
./a.out
Creating thread 0
Creating thread 1
0: Hello World!
Completed join with thread 0 status= 0
1: Hello World!
Completed join with thread 1 status= 0
done
zsh: segmentation fault ./a.out
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/25377] [4.2 Regression] weak_ref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
2005-12-13 13:10 ` [Bug libfortran/25377] " jakub at gcc dot gnu dot org
2005-12-13 16:13 ` jb at gcc dot gnu dot org
@ 2006-01-29 17:42 ` pinskia at gcc dot gnu dot org
2006-01-31 16:24 ` [Bug target/25377] [4.2 Regression] weakref " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-29 17:42 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Component|libfortran |middle-end
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2006-01-29 17:42:14
date| |
Summary|libgfortran/io/transfer.c:21|[4.2 Regression] weak_ref
|59 unlock_unit causes |sibcalled with -fPIC
|segfault |
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-01-29 17:42 ` [Bug middle-end/25377] [4.2 Regression] weak_ref sibcalled with -fPIC pinskia at gcc dot gnu dot org
@ 2006-01-31 16:24 ` pinskia at gcc dot gnu dot org
2006-01-31 16:26 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 16:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-01-31 16:24 -------
Reduced testcase:
int f(void);
static typeof(f) g __attribute__((weakref("f")));
int h(void)
{
return g();
}
-----
Actually is obviously why x86 goes wrong:
in ix86_function_ok_for_sibcall:
/* If we are generating position-independent code, we cannot sibcall
optimize any indirect call, or a direct call to a global function,
as the PLT requires %ebx be live. */
if (!TARGET_64BIT && flag_pic && (!decl || TREE_PUBLIC (decl)))
return false;
TREE_PUBLIC Is the wrong check here.
s390 fixed it a different correct way:
http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00646.html
See the thread:
http://gcc.gnu.org/ml/gcc/2005-12/msg00718.html
Again checking TREE_PUBLIC is not the correct check really.
In fact reading tree.h, it seems so too as it is just commenting about the
name:
nonzero means name is to be accessible from outside this module.
Which has nothing to do with the function being external.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |target
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
Summary|[4.2 Regression] weak_ref |[4.2 Regression] weakref
|sibcalled with -fPIC |sibcalled with -fPIC
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (3 preceding siblings ...)
2006-01-31 16:24 ` [Bug target/25377] [4.2 Regression] weakref " pinskia at gcc dot gnu dot org
@ 2006-01-31 16:26 ` pinskia at gcc dot gnu dot org
2006-01-31 16:42 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 16:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2006-01-31 16:26 -------
Testing the obvious fix like what s390 did.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pinskia at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (4 preceding siblings ...)
2006-01-31 16:26 ` pinskia at gcc dot gnu dot org
@ 2006-01-31 16:42 ` pinskia at gcc dot gnu dot org
2006-02-01 1:17 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 16:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2006-01-31 16:42 -------
And yes that fixed my reduced testcase.
The patch is:
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 110396)
+++ config/i386/i386.c (working copy)
@@ -2211,7 +2211,7 @@ ix86_function_ok_for_sibcall (tree decl,
/* If we are generating position-independent code, we cannot sibcall
optimize any indirect call, or a direct call to a global function,
as the PLT requires %ebx be live. */
- if (!TARGET_64BIT && flag_pic && (!decl || TREE_PUBLIC (decl)))
+ if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl)))
return false;
if (decl)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (5 preceding siblings ...)
2006-01-31 16:42 ` pinskia at gcc dot gnu dot org
@ 2006-02-01 1:17 ` pinskia at gcc dot gnu dot org
2006-02-03 0:10 ` rth at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-01 1:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2006-02-01 01:17 -------
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00005.html
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2006-
| |02/msg00005.html
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (6 preceding siblings ...)
2006-02-01 1:17 ` pinskia at gcc dot gnu dot org
@ 2006-02-03 0:10 ` rth at gcc dot gnu dot org
2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rth at gcc dot gnu dot org @ 2006-02-03 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rth at gcc dot gnu dot org 2006-02-03 00:10 -------
*** Bug 25527 has been marked as a duplicate of this bug. ***
--
rth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dev at stuffit dot at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (7 preceding siblings ...)
2006-02-03 0:10 ` rth at gcc dot gnu dot org
@ 2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
2006-02-05 15:01 ` pinskia at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-03 3:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pinskia at gcc dot gnu dot org 2006-02-03 03:57 -------
Fixed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (8 preceding siblings ...)
2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
@ 2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
2006-02-05 15:01 ` pinskia at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-03 3:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pinskia at gcc dot gnu dot org 2006-02-03 03:56 -------
Subject: Bug 25377
Author: pinskia
Date: Fri Feb 3 03:56:55 2006
New Revision: 110537
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110537
Log:
2006-02-02 Andrew Pinski <pinskia@physics.uc.edu>
PR target/25377
* config/i386/i386.c (ix86_function_ok_for_sibcall):
Use targetm.binds_local_p instead of TREE_PUBLIC.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/25377] [4.2 Regression] weakref sibcalled with -fPIC
2005-12-12 20:03 [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault jb at gcc dot gnu dot org
` (9 preceding siblings ...)
2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
@ 2006-02-05 15:01 ` pinskia at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-05 15:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pinskia at gcc dot gnu dot org 2006-02-05 15:01 -------
*** Bug 26104 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |magnus_os at yahoo dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25377
^ permalink raw reply [flat|nested] 12+ messages in thread