threads and file locking doesn't work correct

Trevor Johnson (kukuk@uni-paderborn.de)
Tue, 24 Feb 1998 10:45:06 +0100 (MET)


Hello,

I have a big problem with file locking and threads under Linux.
Before I start threads, I create a pid file which will be locked with fcntl.
After killing the program (killall or Ctrl-C), the lock will not be
removed always. When starting the program again, I get the error message,
that pid <xxx> owns the lock, but there is no program running with this pid.

In this cases, a cat /proc/locks gives a core dump, and I get the
following message in the log file:

Feb 24 08:40:25 vt kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000008
Feb 24 08:40:25 vt kernel: current->tss.cr3 = 020fe000,
Feb 24 08:40:25 vt kernel: *pde = 00000000
Feb 24 08:40:25 vt kernel: Oops: 0000
Feb 24 08:40:25 vt kernel: CPU: 1
Feb 24 08:40:25 vt kernel: EIP: 0010:[<c0135175>]
Feb 24 08:40:25 vt kernel: EFLAGS: 00010282
Feb 24 08:40:25 vt kernel: eax: 00000000 ebx: 00000000 ecx: 00000001 edx: c01ae806
Feb 24 08:40:25 vt kernel: esi: c081f380 edi: c081f380 ebp: 00000c00 esp: c0397ef4
Feb 24 08:40:25 vt kernel: ds: 0018 es: 0018 ss: 0018
Feb 24 08:40:25 vt kernel: Process cat (pid: 794, process nr: 82, stackpage=c0397000)
Feb 24 08:40:25 vt kernel: Stack: 00000000 00000001 c081f380 c01352a8 c081f380 00000001 c01ae806 00000000
Feb 24 08:40:25 vt kernel: c0397f94 c16969d8 00000c00 c1e01134 00000000 00000001 c1e01134 c081f380
Feb 24 08:40:25 vt kernel: c04ac000 c014acc9 c04ac000 c0397f94 00000000 00000c00 c04ac000 c1578554
Feb 24 08:40:25 vt kernel: Call Trace: [<c01352a8>] [<c01ae806>] [<c014acc9>] [<c014ae36>] [<c0111f6f>] [<c0128cde>] [<c0109f42>]
Feb 24 08:40:25 vt kernel: Code: 8b 78 08 52 51 68 81 e7 1a c0 68 64 6d 1e c0 e8 8b 2e 07 00

Output from ksymoops:

Using `/boot/System.map' to map addresses to symbols.

>>EIP: c0135175 <lock_get_status+15/100>
Trace: c01352a8 <get_locks_status+48/1dc>
Trace: c01ae806 <tvecs+2476/4ca1>
Trace: c014acc9 <get_root_array+1a9/1b8>
Trace: c014ae36 <array_read+be/1e0>
Trace: c0111f6f <do_page_fault+1b7/3d0>
Trace: c0128cde <sys_read+116/188>
Trace: c0109f42 <system_call+3a/40>
Code: c0135175 <lock_get_status+15/100>
Code: c0135175 <lock_get_status+15/100> 8b 78 08 movl 0x8(%eax),%edi
Code: c0135178 <lock_get_status+18/100> 52 pushl %edx
Code: c0135179 <lock_get_status+19/100> 51 pushl %ecx
Code: c013517a <lock_get_status+1a/100> 68 81 e7 1a c0 pushl $0xc01ae781
Code: c0135185 <lock_get_status+25/100> 68 64 6d 1e c0 pushl $0xc01e6d64
Code: c013518a <lock_get_status+2a/100> e8 8b 2e 07 00 call c01a8014 <sprintf>
k

Any chance to fix this ? I need threads and file locking.

Thanks,

Thorsten

-- 
Thorsten Kukuk     kukuk@uni-paderborn.de                FB17/Informatik
                   http://www-vt.uni-paderborn.de/~kukuk

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu