Possible cygwin bug: NFS locks stay open after pipe output

Michael Teske mteske@csksoftware.com
Wed Apr 3 01:23:00 GMT 2002


Hi!

This problem was reproducable with two different nfs clients for Windows NT, 
Solstice and MS Unix Services for Windows and a Solaris 7 nfs server:

If I use command pipes either in a shell or in a shell script and redirect the 
result to a file which is on a nfs-mounted drive, this file stays locked even after 
the complete pipe is done.

The simplest example for reproducing this is
echo xx | grep -v test > xx.def
After this, the file xx.def stays locked. One can verify this by trying to use the file with the MS linker, e.g.
link xx.o /def:xx.def
will complain that it cannot open the file (it probably tries to open the file exclusively).

After I found this behaviour I of course suspected the nfs clients as being guilty 
since this works fine on SMB-mounted drives or the local disk, but then 
I found that putting the pipe in a subshell works fine, e.g.
(echo xx | grep -v test) > xx.def 
doesn't leave a lock.

I'm not sure how to debug this any further, so I thought I ask here if somebody has other ideas than me.

I have strace output here for both cases, but since they are rather long (200 kB each) 
I'll send them on request only. I have grepped them for the name of the output file and this is the result:
a) first case (not working, echo xx | grep -v test > xx.def):

 $ grep xx.def st.txt
 2340 1008132 [main] bash 250 _open: open (xx.def, 0x601)
  515 1008647 [main] bash 250 normalize_posix_path: src xx.def
  508 1010161 [main] bash 250 normalize_posix_path: /cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def = normalize_posix_path (xx.def)
  518 1010679 [main] bash 250 mount_info::conv_to_win32_path: conv_to_win32_path (/cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def)
  525 1011204 [main] bash 250 mount_info::cygdrive_win32_path: src '/cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def', dst 'f:\CSK-Pricer\src\PriceEngine\xx.def'
  524 1011728 [main] bash 250 mount_info::conv_to_win32_path: src_path /cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def, dst f:\CSK-Pricer\src\PriceEngine\xx.def,
flags 0x22, rc 0
  533 1015063 [main] bash 250 symlink_info::check: 0 = symlink.check (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x22F2B4) (0x22)
  532 1015595 [main] bash 250 path_conv::check: root_dir(f:\), this->path(f:\CSK-Pricer\src\PriceEngine\xx.def), set_has_acls(0)
  512 1016637 [main] bash 250 fhandler_base::open: (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
  958 1017595 [main] bash 250 fhandler_base::open: 0x11C = CreateFileA (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x40000000, 0x7, 0x22F6F4, 0x2, 0x80, 0)
  513 1018693 [main] bash 250 fhandler_base::open: 1 = fhandler_base::open (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
  522 1019215 [main] bash 250 fhandler_disk_file::open: 1 = fhandler_disk_file::open (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
  508 1019723 [main] bash 250 _open: 3 = open (xx.def, 0x601)
  621 1022004 [main] bash 250 dtable::dup_worker: duped 'xx.def' old 0x11C, new 0x138
  502 1025360 [main] bash 250 fhandler_base::close: closing 'xx.def' handle 0x11C
  639 1174269 [main] bash 250! fhandler_base::close: closing 'xx.def' handle 0x138
  508   77549 [main] grep 250 fhandler_base::close: closing 'xx.def' handle 0x138

b) second case (working fine, (echo xx | grep -v test) > xx.def):

 3095  797841 [main] bash 231 _open: open (xx.def, 0x601)
  530  798371 [main] bash 231 normalize_posix_path: src xx.def
  503  799878 [main] bash 231 normalize_posix_path: /cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def = normalize_posix_path (xx.def)
  529  800407 [main] bash 231 mount_info::conv_to_win32_path: conv_to_win32_path (/cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def)
  523  800930 [main] bash 231 mount_info::cygdrive_win32_path: src '/cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def', dst 'f:\CSK-Pricer\src\PriceEngine\xx.def'
  511  801441 [main] bash 231 mount_info::conv_to_win32_path: src_path /cygdrive/f/CSK-Pricer/src/PriceEngine/xx.def, dst f:\CSK-Pricer\src\PriceEngine\xx.def,
flags 0x22, rc 0
  527  804941 [main] bash 231 symlink_info::check: 0 = symlink.check (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x22F428) (0x22)
  518  805459 [main] bash 231 path_conv::check: root_dir(f:\), this->path(f:\CSK-Pricer\src\PriceEngine\xx.def), set_has_acls(0)
  504  806502 [main] bash 231 fhandler_base::open: (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
 1058  807560 [main] bash 231 fhandler_base::open: 0xC4 = CreateFileA (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x40000000, 0x7, 0x22F868, 0x2, 0x80, 0)
  580  809085 [main] bash 231 fhandler_base::open: 1 = fhandler_base::open (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
  556  809641 [main] bash 231 fhandler_disk_file::open: 1 = fhandler_disk_file::open (f:\CSK-Pricer\src\PriceEngine\xx.def, 0x601)
  589  810230 [main] bash 231 _open: 3 = open (xx.def, 0x601)
  504  812546 [main] bash 231 dtable::dup_worker: duped 'xx.def' old 0xC4, new 0xD8
  484  815541 [main] bash 231 fhandler_base::close: closing 'xx.def' handle 0xC4
  530  879072 [main] bash 211 fhandler_base::close: closing 'xx.def' handle 0xD8
  606 1262343 [main] bash 148! fhandler_base::close: closing 'xx.def' handle 0xD8
  503   76665 [main] grep 148 fhandler_base::close: closing 'xx.def' handle 0xD8
  532 1459461 [main] bash 231 fhandler_base::close: closing 'xx.def' handle 0xD8



The thing that puzzles me is that in the second case, the fhandler_base::close:-line is there 5 times, 
while it's only 3 times in the first case...

I would be very grateful if somebody could give me a hint.

Greetings, Michael


-- 
Michael Teske



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list