This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
read/thread/deadlock
- To: libc-alpha@cygnus.com
- Subject: read/thread/deadlock
- From: marc@laendle
- Date: Fri, 11 Sep 1998 02:45:06 +0200
>Submitter-Id: net
>Originator: Marc Lehmann
>Organization:
>
>Confidential: no
>Synopsis: deadlock on various io functions.
>Severity: serious
>Priority: low
>Category: libc
>Class: sw-bug
>Release: libc-2.0.94
>Environment:
Host type: i686-pc-linux-gnu
System: Linux cerebro 2.1.120 #46 SMP Sat Sep 5 23:52:04 CEST 1998 i686
Architecture: i686
Addons: linuxthreads crypt
Build CC: gcc
Compiler version: egcs-2.91.57 19980901 (egcs-1.1 release)
Kernel headers: 2.1.121
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: no
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
>Description:
perl compiled with thread support freezes in the testsuite on the t/io/read.t test. attaching
to the process gives me the following backtrace:
#0 0x4005bdc1 in __syscall_rt_sigsuspend ()
#1 0x4005ada8 in __sigsuspend (set=0xbffff568) at ../sysdeps/unix/sysv/linux/sigsuspend.c:44
#2 0x40168479 in __pthread_lock (lock=0x8110eb8) at restart.h:32
#3 0x4016643d in __pthread_mutex_lock (mutex=0x8110ea8) at mutex.c:84
#4 0x40167ea7 in __flockfile (stream=0x8110e10) at lockfile.c:32
#5 0x4008bae4 in _IO_seekoff (fp=0x8110e10, offset=0, dir=0, mode=3) at ioseekoff.c:41
#6 0x4008c474 in fseek (fp=0x8110e10, offset=0, whence=0) at fseek.c:39
#7 0x80ec3bf in Perl_do_seek ()
incidently, fseek locks the stream before calling ioseekfoff, which tries to
do the same. after removing the lock, the testsuite stopped again at various other
tests, similar diagnose.
>How-To-Repeat:
compile perl with support for threads, make test.
>Fix:
This patch seems to work, at least with perl, but I can't imagine
this being correct.
1998-09-11 02:55:03 Marc Lehmann <pcg@goof.com>
* libio/fseek.c (fseek),
libio/fseeko.c (fseeko),
libio/fseeko64.c (fseeko64),
libio/ioftell.c (_IO_ftell),
libio/ftello.c (ftello),
libio/ftello64.c (ftello64),
libio/rewind.c (rewind),
libio/iofsetpos.c (_IO_fsetpos),
libio/iofsetpos64.c (_IO_fsetpos64),
libio/iofgetpos.c (_IO_fgetpos),
libio/iofgetpos64.c (_IO_fgetpos64): Do not lock here.
diff -ur libio/fseek.c libio/fseek.c
--- libio/fseek.c Fri Sep 11 02:28:10 1998
+++ libio/fseek.c Fri Sep 11 02:28:47 1998
@@ -34,10 +34,6 @@
{
int result;
CHECK_FILE (fp, -1);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
result = _IO_fseek (fp, offset, whence);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
return result;
}
diff -ur libio/fseeko.c libio/fseeko.c
--- libio/fseeko.c Mon Jun 8 21:31:03 1998
+++ libio/fseeko.c Fri Sep 11 03:00:38 1998
@@ -34,10 +34,6 @@
{
int result;
CHECK_FILE (fp, -1);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
result = _IO_fseek (fp, offset, whence);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
return result;
}
diff -ur libio/fseeko64.c libio/fseeko64.c
--- libio/fseeko64.c Mon Jun 8 21:31:03 1998
+++ libio/fseeko64.c Fri Sep 11 03:01:44 1998
@@ -36,11 +36,7 @@
#ifdef _G_LSEEK64
int result;
CHECK_FILE (fp, -1);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
result = _IO_fseek (fp, offset, whence);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
return result;
#else
__set_errno (ENOSYS);
diff -ur libio/ftello.c libio/ftello.c
--- libio/ftello.c Mon Jun 8 21:31:03 1998
+++ libio/ftello.c Fri Sep 11 02:59:40 1998
@@ -34,11 +34,7 @@
{
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
if (pos == _IO_pos_BAD)
{
#ifdef EIO
diff -ur libio/ftello64.c libio/ftello64.c
--- libio/ftello64.c Mon Jun 8 21:31:03 1998
+++ libio/ftello64.c Fri Sep 11 02:59:44 1998
@@ -35,11 +35,7 @@
#ifdef _G_LSEEK64
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
if (pos == _IO_pos_BAD)
{
#ifdef EIO
diff -ur libio/iofgetpos.c libio/iofgetpos.c
--- libio/iofgetpos.c Fri Sep 11 02:54:43 1998
+++ libio/iofgetpos.c Fri Sep 11 02:54:52 1998
@@ -33,11 +33,7 @@
{
_IO_fpos_t pos;
CHECK_FILE (fp, EOF);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
if (pos == _IO_pos_BAD)
{
/* ANSI explicitly requires setting errno to a positive value on
diff -ur libio/iofgetpos64.c libio/iofgetpos64.c
--- libio/iofgetpos64.c Mon Jun 8 21:31:03 1998
+++ libio/iofgetpos64.c Fri Sep 11 02:58:15 1998
@@ -34,11 +34,7 @@
#ifdef _G_LSEEK64
_IO_fpos64_t pos;
CHECK_FILE (fp, EOF);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
if (pos == _IO_pos_BAD)
{
/* ANSI explicitly requires setting errno to a positive value on
diff -ur libio/iofsetpos.c libio/iofsetpos.c
--- libio/iofsetpos.c Mon Jun 8 21:31:03 1998
+++ libio/iofsetpos.c Fri Sep 11 03:19:02 1998
@@ -33,8 +33,6 @@
{
int result;
CHECK_FILE (fp, EOF);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD)
{
/* ANSI explicitly requires setting errno to a positive value on
@@ -47,8 +45,6 @@
}
else
result = 0;
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
return result;
}
diff -ur libio/iofsetpos64.c libio/iofsetpos64.c
--- libio/iofsetpos64.c Mon Jun 8 21:31:03 1998
+++ libio/iofsetpos64.c Fri Sep 11 03:19:08 1998
@@ -34,8 +34,6 @@
#ifdef _G_LSEEK64
int result;
CHECK_FILE (fp, EOF);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD)
{
/* ANSI explicitly requires setting errno to a positive value on
@@ -48,8 +46,6 @@
}
else
result = 0;
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
return result;
#else
__set_errno (ENOSYS);
diff -ur libio/ioftell.c libio/ioftell.c
--- libio/ioftell.c Fri Sep 11 02:49:08 1998
+++ libio/ioftell.c Fri Sep 11 02:49:15 1998
@@ -33,11 +33,7 @@
{
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
if (pos == _IO_pos_BAD)
{
#ifdef EIO
diff -ur libio/rewind.c libio/rewind.c
--- libio/rewind.c Mon Jun 8 21:31:03 1998
+++ libio/rewind.c Fri Sep 11 03:12:52 1998
@@ -31,9 +31,5 @@
_IO_FILE *fp;
{
CHECK_FILE (fp, );
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
_IO_rewind (fp);
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
}