CPython multiprocess fork failing with gdb/lldb attached on OS X <p>Trying to run the following code in CPython 2.7.12 with either gdb or lldb attached fails:</p> <pre><code>import multiprocessing as mp mp.Manager() </code></pre> <p>The debugger sees something like:</p> <pre><code>$ lldb -f python (lldb) target create "/usr/local/bin/python" Current executable set to '/usr/local/bin/python' (x86_64). (lldb) r Process 1857 launched: '/usr/local/bin/python' (x86_64) Process 1857 stopped * thread #1: tid = 0x1afeb, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = exec frame #0: 0x00007fff5fc01000 dyld`_dyld_start dyld`_dyld_start: -&gt; 0x7fff5fc01000 &lt;+0&gt;: popq %rdi 0x7fff5fc01001 &lt;+1&gt;: pushq $0x0 0x7fff5fc01003 &lt;+3&gt;: movq %rsp, %rbp 0x7fff5fc01006 &lt;+6&gt;: andq $-0x10, %rsp (lldb) c Process 1857 resuming Python 2.7.12 (default, Oct 11 2016, 05:24:00) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import multiprocessing &gt;&gt;&gt; multiprocessing.Manager() Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 99, in Manager m.start() File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/managers.py", line 528, in start self._address = reader.recv() EOFError </code></pre> <p>Along with that output, I get the standard OS X crash dialog, from that, notably:</p> <pre><code>Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Application Specific Information: dyld: in dlopen() crashed on child side of fork pre-exec Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 dyld 0x00007fff5fc0d35b gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) + 1 1 ??? 000000000000000000 0 + 0 2 dyld 0x00007fff5fc0482a dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) + 755 3 dyld 0x00007fff5fc0e75d ImageLoader::link(ImageLoader::LinkContext const&amp;, bool, bool, bool, ImageLoader::RPathChain const&amp;) + 89 4 dyld 0x00007fff5fc04a12 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&amp;) + 149 5 dyld 0x00007fff5fc0c29f dlopen + 450 6 libdyld.dylib 0x00007fff87ce279c dlopen + 59 7 org.python.python 0x00000001000b8182 _PyImport_GetDynLoadFunc + 309 8 org.python.python 0x00000001000a3230 _PyImport_LoadDynamicModule + 96 </code></pre> <p>This similarly happens in gdb regardless of the setting of <code>detach-on-fork</code>.</p> <p>How can I run CPython under a debugger with multiprocessing code?</p>