NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/41549: Sometimes fcntl(,F_SETLK)'s lock remains after the process exits.
>Number: 41549
>Category: kern
>Synopsis: Sometimes fcntl(,F_SETLK)'s lock remains after the process
>exits.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 06 05:40:00 +0000 2009
>Originator: HITOSHI OSADA
>Release: NetBSD 5.99.13 (2009/06/05)
>Organization:
None
>Environment:
System: NetBSD amd690g 5.99.13 NetBSD 5.99.13 (AMD690G) #3: Thu Jun 4 21:14:26
JST 2009 root@amd690g:/NetBSD-obj/src-obj/sys/arch/amd64/compile/AMD690G amd64
Architecture: x86_64
Machine: amd64
>Description:
Sometimes fcntl(, F_SETLK, ...)'s lock remains after the process exits.
The lock remains until the lockfile removed.
firefox3 sometimes failed as "firefox already exists but not responding".
>How-To-Repeat:
$ while ./locktest; do ./locktest; done
(...doing some heavy jobs at background...)
locktest: Resource temporarily unavailable
$ ./locktest
locktest: Resource temporarily unavailable
$ rm .testlockfile
$ ./locktest
$
locktest.c:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
/*
* Codes from firefox-3.0.10 (nsProfileLock.cpp)
*/
int mLockFileDesc;
int mHaveLock;
int
locktest(const char *filename)
{
int rv = 0;
mLockFileDesc = open(filename,
O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (mLockFileDesc != -1)
{
struct flock lock;
lock.l_start = 0;
lock.l_len = 0;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
struct flock testlock = lock;
if (fcntl(mLockFileDesc, F_GETLK, &testlock) == -1)
{
close(mLockFileDesc);
mLockFileDesc = -1;
rv = -1;
}
else if (fcntl(mLockFileDesc, F_SETLK, &lock) == -1)
{
close(mLockFileDesc);
mLockFileDesc = -1;
perror("locktest");
if (errno == EAGAIN || errno == EACCES)
rv = -2;
else
rv = -1;
}
else
mHaveLock = 1;
}
else
{
printf("Failed to open lock file.");
rv = -1;
}
return rv;
}
int
main(void)
{
return (locktest(".testlockfile") * -1);
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index