colesbury / nogil-3.12

Multithreaded Python without the GIL (experimental rebase on 3.12)
Other
143 stars 7 forks source link

nogil-3.12 fails to build on Mac (M1 Pro) #4

Closed smontanaro closed 1 year ago

smontanaro commented 1 year ago

Bug report

I thought I would catch up on the nogil-3.12 stuff, so fetched and pulled from:

git@github.com:colesbury/nogil-3.12.git

then executed:

make distclean
./configure && make -j && make test

but the build step failed with a segfault building deepfreeze.c:

% make
./_bootstrap_python ./Tools/build/deepfreeze.py \
    Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap \
    Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external \
    Python/frozen_modules/zipimport.h:zipimport \
    Python/frozen_modules/abc.h:abc \
    Python/frozen_modules/codecs.h:codecs \
    Python/frozen_modules/io.h:io \
    Python/frozen_modules/_collections_abc.h:_collections_abc \
    Python/frozen_modules/_sitebuiltins.h:_sitebuiltins \
    Python/frozen_modules/genericpath.h:genericpath \
    Python/frozen_modules/ntpath.h:ntpath \
    Python/frozen_modules/posixpath.h:posixpath \
    Python/frozen_modules/os.h:os \
    Python/frozen_modules/site.h:site \
    Python/frozen_modules/stat.h:stat \
    Python/frozen_modules/importlib.util.h:importlib.util \
    Python/frozen_modules/importlib.machinery.h:importlib.machinery \
    Python/frozen_modules/runpy.h:runpy \
    Python/frozen_modules/__hello__.h:__hello__ \
    Python/frozen_modules/__phello__.h:__phello__ \
    Python/frozen_modules/__phello__.ham.h:__phello__.ham \
    Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs \
    Python/frozen_modules/__phello__.spam.h:__phello__.spam \
    Python/frozen_modules/frozen_only.h:frozen_only \
    -o Python/deepfreeze/deepfreeze.c
make: *** [Python/deepfreeze/deepfreeze.c] Segmentation fault: 11

When I run it under control of lldb, I get this output:

Process 70276 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffffffff168)
    frame #0: 0x00000001001c31b4 _bootstrap_python`_Py_queue_object [inlined] find_thread_state(bucket=0x000000010043b150, thread_id=8002493952) at pyrefcnt.c:32:24 [opt]
   29       llist_for_each(node, &bucket->threads) {
   30           PyThreadStateImpl *ts;
   31           ts = llist_data(node, PyThreadStateImpl, brc.bucket_node);
-> 32           if (ts->tstate.fast_thread_id == thread_id) {
   33               return ts;
   34           }
   35       }
Target 0: (_bootstrap_python) stopped.
warning: _bootstrap_python was compiled with optimization - stepping may behave oddly; variables may not be available.

It didn't give me a prompt (I've never used lldb before), so can't provide a more complete backtrace. Let me know if there's more info I can provide which would help identify source of the problem.

Your environment

MacBook Pro, Apple M1 Pro CPU, macOS Ventura 13.4

% gcc --version 
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
colesbury commented 1 year ago

Hi @smontanaro - thanks for the bug report. I've been staging bug fixes in the nogil-3.12-bugfix branch. Please use that branch. It has a fix for ARM64 CPUs (including Apple's M1).

smontanaro commented 1 year ago

Got it, thanks.

smontanaro commented 1 year ago

@colesbury Sorry, but I get the same error and stack frame on the nogil-3.12-bugfix branch.

colesbury commented 1 year ago

@smontanaro Sorry about that - I had a local commit that I forgot to push. If you pull and rebuild (the nogil-3.12-bugfix branch) it should be fixed now.

smontanaro commented 1 year ago

Thanks. That fixed it.