Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004666OCamlOCaml generalpublic2008-12-06 21:172009-04-19 11:02
Reportergguyomarch 
Assigned Toxleroy 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.11.0+beta 
Target VersionFixed in Version3.11.1+dev 
Summary0004666: Execv unix calls fail with threaded program on Mac OS X.
DescriptionPrior to bug fix for PR#457, threaded programs could overcome the following limitation of mac os x execve (execv failing with EOPNOTSUPP when a process as multiple active threads):

http://uninformed.org/index.cgi?v=1&a=1&p=16 [^]
http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00836.html [^]

by forking first, see example below.

I do not know if there is a right thing to do though.

Thanks,
Gregory.

(* fork_exec.ml *)
(* Compiled with:
        ocamlbuild -tag use_unix -cflags "-I +vmthreads" -lflags "-I +vmthreads" -libs unix,threads fork_exec.byte
   works on mac os x, but with the following, it will fails in execvp with EOPNOTSUPP in 3.11:
        ocamlbuild -tag use_unix -cflags "-I +threads" -lflags "-I +threads" -libs unix,threads fork_exec.byte
   Used to work in 3.10.2.
 *)
let () =
    let t = Thread.create (fun () -> ()) () in
    Thread.join t;
    Unix.handle_unix_error
        (fun () ->
            match Unix.fork () with
            | 0 -> Unix.execvp "ls" [| "ls"; "-l" |];
            | pid -> ()
        ) ();
;;

Gregoire Henri said:
> PR#4577: reinitialize thread machinery after fork
> http://caml.inria.fr/mantis/view.php?id=4577 [^]
>
> The trick of systematically calling fork before exec in a threaded
> program does not work anymore, because the ocaml Unix.fork restart a
> thread after forking.

TagsNo tags attached.
Attached Files

- Relationships
related to 0004725closed Unix.system .exec Sys.command failures when threading fuctions are called 

-  Notes
(0004795)
xleroy (administrator)
2008-12-12 09:52

That's a nasty bug in MacOS X. One possible fix would be to create the 'tick' thread on demand, i.e. the first time a thread is created after the initial launch of the program or after a fork (in the child process). I'll look into this.
(0004798)
xleroy (administrator)
2008-12-14 19:17

Tentative fix (on-demand creation of tick thread) in 3.11 release branch, to be included in 3.11.1 if it works.
(0004806)
xleroy (administrator)
2008-12-19 09:43

The same problem was reported under FreeBSD. The fix in the release branch appears to fix it.
(0004821)
doligez (administrator)
2009-01-24 19:41

From: Mike Spivey

I wanted to add a note in Mantis (but couldn't see how to do it) to say
that I had encountered the problem described in 0004666 in a program that
contains OCaml + LablGTK + GTK+OSX + threads + sockets. The fix that is
in the 3.11 release branch on CVS solved the problem for me.

Best wishes,

-- Mike Spivey
(0004824)
xleroy (administrator)
2009-01-26 18:15

Based on feedback so far, the fix appears to work. I'm closing this PR.

- Issue History
Date Modified Username Field Change
2008-12-06 21:17 gguyomarch New Issue
2008-12-12 09:52 xleroy Note Added: 0004795
2008-12-12 09:52 xleroy Assigned To => xleroy
2008-12-12 09:52 xleroy Status new => acknowledged
2008-12-14 19:17 xleroy Note Added: 0004798
2008-12-14 19:17 xleroy Status acknowledged => resolved
2008-12-14 19:17 xleroy Resolution open => fixed
2008-12-19 09:43 xleroy Note Added: 0004806
2009-01-24 19:41 doligez Note Added: 0004821
2009-01-26 18:15 xleroy Note Added: 0004824
2009-01-26 18:15 xleroy Status resolved => closed
2009-03-28 17:48 xleroy Relationship added related to 0004725
2009-04-19 11:02 xleroy Fixed in Version => 3.11.1+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker