Problem with MAP_PRIVATE for fork() using pypy
Uwe F. Mayer
uwe_f_mayer@yahoo.com
Sun Jun 10 00:20:00 GMT 2012
I have recently patched pypy (http://www.pypy.org) to compile under Cygwin. Pypy implements a Python interpreter with a Just In Time (JIT) compiler. At runtime pypy uses a MAP_PRIVATE anonymous mmap to allocate memory for its JIT. This seems to be cause of fork() calls failing. A sample error message is included below. I have discussed this problem at length with the pypy developers. The discussion is online at:
http://www.mail-archive.com/pypy-dev@python.org/msg02448.html
Finally I hacked the pypy sources and replaced the MAP_PRIVATE anonymous mmap allocation with MAP_SHARED at the place where pypy allocates its JIT temporary memory, and the code runs fine (but that's not a solution for pypy, as their JIT child and parent processes likely will drift apart for any real non-toy program and do need separate memory space). From what the pypy folks say, this is not a pypy issue but a Cygwin issue.
$ ./pypy-c
Python 2.7.2 (ffd032c196fb+, May 31 2012, 23:19:38)
[PyPy 1.9.1-dev0 with GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``correct code doesnt need any
tests <duck>''
>>>> import os
>>>> os.fork()
3 [main] pypy-c 5672 fixup_mmaps_after_fork: ReadProcessMemory failed for MAP_PRIVATE address 0xB0010000, Win32 error 998
172 [main] pypy-c 5672 D:\pypy\pypy-jit\pypy\pypy\translator\goal\pypy-c: *** fatal error in forked process - recreate_mmaps_after_fork_failed
478 [main] pypy-c 5672 open_stackdumpfile: Dumping stack trace to pypy-c.stackdump
1 [main] pypy-c 6112 fork: child -1 - forked process 5672 died unexpectedly, retry 0, exit code 256, errno 11
Traceback (most recent call last):
File "<console>", line 1, in <module>
OSError: [Errno 11] Resource temporarily unavailable
>>>>
PS Attached is an output of cygcheck, and the relevant portion of an strace.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 253038 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120610/25145ab6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_os_fork_opt=jit.log
Type: application/octet-stream
Size: 6164 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120610/25145ab6/attachment-0001.obj>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list