Opened 4 years ago

Closed 3 years ago

#5319 closed bug (wontfix)

MacOS X + executeFile + -threaded = "Operation not supported"

Reported by: PHO Owned by:
Priority: high Milestone: 7.4.1
Component: libraries/unix Version: 7.0.3
Keywords: thread, exec Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case: executeFile001
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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

Mac OS X has an undocumented behavior concerning 'execve(2)' inside a
threaded process. If a process tries to call 'execve(2)' and has more
than one native thread, the kernel returns 'EOPNOTSUPP'. This prevents
'executeFile' from working when the threaded runtime is used.

% ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> System.Posix.Process.executeFile "/bin/sh" False [] Nothing
Loading package unix-2.4.2.0 ... linking ... done.
*** Exception: /bin/sh: executeFile: failed (Operation not supported)
Prelude> 
Leaving GHCi.
% uname
Darwin

To work around this, we have to 'fork(2)' before calling 'execve(2)',
to make sure there is only a single active thread.

Change History (8)

comment:1 Changed 4 years ago by igloo

  • Milestone set to 7.4.1
  • Priority changed from normal to high

Thanks for the report.

comment:2 Changed 4 years ago by igloo

  • Owner set to igloo

comment:3 Changed 3 years ago by igloo

  • Owner igloo deleted

I can't reproduce this; any idea why not?

212:~ ian$ ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> System.Posix.Process.executeFile "/bin/sh" False [] Nothing
Loading package unix-2.4.2.0 ... linking ... done.
sh-3.2$ exit
exit
212:~ ian$ 

comment:4 Changed 3 years ago by igloo

  • Status changed from new to infoneeded

comment:5 Changed 3 years ago by igloo

  • Test Case set to executeFile001

comment:6 Changed 3 years ago by arkx

Just another data point: I could not reproduce this either. Running on Lion.

~ $ ghci
GHCi, version 7.2.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> System.Posix.Process.executeFile "/bin/sh" False [] Nothing
Loading package unix-2.5.0.0 ... linking ... done.
sh-3.2$ exit
~ $ uname -v 
Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011;
root:xnu-1699.24.8~1/RELEASE_X86_64

comment:7 Changed 3 years ago by PHO

Oh, really?
If the recent Darwin kernels don't have this limitation, it might be reasonable to close this ticket. The problem happens at least on Leopard:

% uname -v
Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009;
root:xnu-1228.15.4~1/RELEASE_PPC

comment:8 Changed 3 years ago by igloo

  • Resolution set to wontfix
  • Status changed from infoneeded to closed

I'll close this ticket, then, but if anyone wants to make a tested patch then we can apply it.

Note: See TracTickets for help on using tickets.