|Anonymous | Login | Signup for a new account||2016-02-09 00:09 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005069||OCaml||OCaml general||public||2010-06-08 21:29||2011-05-12 17:15|
|Target Version||Fixed in Version||3.12.1+dev|
|Summary||0005069: caml_sys_open may block while holding runtime lock|
|Description||caml_sys_open in byterun/sys.c uses fcntl to set the FD_CLOEXEC flag (if supported by that platform) on file descriptors after opening a file. Unfortunately, this happens outside of the OCaml runtime lock, which can lead to problems if fcntl blocks.|
We have observed this issue when e.g. opening files on NFS. It seems glibc wraps the fcntl system call in a way that requires it to also call "stat", which is known to block under some circumstances.
Could you please change caml_sys_open to call fcntl in the "blocking section" used to open the file? - Thanks!
|Tags||No tags attached.|
|Attached Files||pr_5069.patch [^] (683 bytes) 2011-05-10 20:15 [Show Content]|
I failed to reproduce this bug and doubt that, as of glibc 2.13, fcntl calls stat while setting FD_CLOSEXEC. The kernel however has a small lock around the fd and it is possible that, on NFS, some operations hold that lock for a bit too long.
The patch to do the fcntl out of the ocaml lock is very simple and probably worth applying just to stray on the safe side.
|The straces back then definitely showed that fcntl was calling "stat", though the problem might also be due to kernel locks. Hard to say, the problem was not reliably reproducible. Newer glibc versions may also behave differently. I agree we should fix this in any case to be on the safe side.|
|Ah, the mystery of the blocking fnctl()... The patch is sweet, though, so I applied it in the 3.12 branch. Will be part of 3.12.1.|
|2010-06-08 21:29||mottl||New Issue|
|2011-05-10 20:15||till||File Added: pr_5069.patch|
|2011-05-10 20:26||till||Note Added: 0005883|
|2011-05-10 21:55||mottl||Note Added: 0005884|
|2011-05-12 17:15||xleroy||Note Added: 0005888|
|2011-05-12 17:15||xleroy||Status||new => closed|
|2011-05-12 17:15||xleroy||Resolution||open => fixed|
|2011-05-12 17:15||xleroy||Fixed in Version||=> 3.12.1+dev|
|Copyright © 2000 - 2011 MantisBT Group|