public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/25377] New: libgfortran/io/transfer.c:2159 unlock_unit causes segfault
@ 2005-12-12 20:03 jb at gcc dot gnu dot org
2005-12-13 13:10 ` [Bug libfortran/25377] " jakub at gcc dot gnu dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: jb at gcc dot gnu dot org @ 2005-12-12 20:03 UTC (permalink / raw)
To: gcc-bugs
I tried to use gfortran together with a library that uses pthreads. This caused
a segfault. Note that my own code didn't directly call pthreads nor use openmp
(this is trunk, not gomp branch).
~/src/benchmark/matmul-bench% gfortran -g -O0 matmul-bench.f90 -o mbgfc-goto
-lgoto -lpthread
~/src/benchmark/matmul-bench% gdb ./mbgfc-goto
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...Using host libthread_db library
"/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) b transfer.c:2159
No source file named transfer.c.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (transfer.c:2159) pending.
(gdb) r
Starting program: /home/joib/src/benchmark/matmul-bench/mbgfc-goto
[Thread debugging using libthread_db enabled]
[New Thread 1076887104 (LWP 30593)]
Breakpoint 2 at 0x40188b98: file ../../../trunk/libgfortran/io/transfer.c, line
2159.
Pending breakpoint "transfer.c:2159" resolved
Single precision matrix multiplication test
[Switching to Thread 1076887104 (LWP 30593)]
Breakpoint 2, *_gfortran_st_write_done (dtp=0xbfa1665c)
at ../../../trunk/libgfortran/io/transfer.c:2159
2159 unlock_unit (dtp->u.p.current_unit);
(gdb) step
*_gfortrani_unlock_unit (u=0x804f118) at
../../../trunk/libgfortran/io/unit.c:555
555 {
(gdb)
538 gthr-posix.h: No such file or directory.
in gthr-posix.h
(gdb)
539 in gthr-posix.h
(gdb)
557 }
(gdb)
*_gfortrani_unlock_unit (u=0xbfa1665c) at gthr-posix.h:539
539 gthr-posix.h: No such file or directory.
in gthr-posix.h
(gdb)
0x402ed223 in in6addr_any () from /lib/tls/i686/cmov/libc.so.6
(gdb)
Single stepping until exit from function in6addr_any,
which has no line number information.
Program received signal SIGSEGV, Segmentation fault.
0x402ed231 in in6addr_any () from /lib/tls/i686/cmov/libc.so.6
--
Summary: libgfortran/io/transfer.c:2159 unlock_unit causes
segfault
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jb at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
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 ` 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
` (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 #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
` (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 #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
end of thread, other threads:[~2006-02-05 15:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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
2006-02-03 3:57 ` pinskia at gcc dot gnu dot org
2006-02-05 15:01 ` pinskia at gcc dot gnu dot org
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).