DawDreamer icon indicating copy to clipboard operation
DawDreamer copied to clipboard

Trouble with conda on macOS

Open woodshop opened this issue 4 years ago • 5 comments

python exits abnormally when importing dawdreamer with an error message similar to the following.

Fatal Python error: PyMUTEX_LOCK(gil->mutex) failed
Python runtime state: unknown

What's strange is that I've been able to successfully compile, import, and execute DawDreamer methods on Linux (Ubuntu 18.04, Python 3.6).

However, I've been running into this issue on macOS 11.2. I've tried compiling using the pybind11 commit referenced in the submodule, as well as the head of the pybind11 master branch. I've tried compiling with Python 3.6, 3.7, 3.8, and 3.9. In all cases, Python crashes when importing dawdreamer with a stack trace similar to the following.

Process:               python3.8 [15931]
Path:                  /Users/USER/*/python3.8
Identifier:            python3.8
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        zsh [81315]
Responsible:           iTerm2 [459]
User ID:               660792939

Date/Time:             2021-02-05 16:34:59.090 -0500
OS Version:            macOS 11.2 (20D64)
Report Version:        12
Bridge OS Version:     5.2 (18P4346)
Anonymous UUID:        9C234BA2-0174-CEDF-ADD9-33AD591B297B


Time Awake Since Boot: 94000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff20623462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff20651610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff205a4720 abort + 120
3   libpython3.8.dylib            	0x0000000111e7afb8 fatal_error + 712
4   libpython3.8.dylib            	0x0000000111e7b253 Py_FatalError + 19
5   libpython3.8.dylib            	0x0000000111e189f2 take_gil + 610
6   libpython3.8.dylib            	0x0000000111e7f4a2 PyGILState_Ensure + 66
7   dawdreamer.so                 	0x000000010f708089 pybind11::detail::get_internals()::gil_scoped_acquire_local::gil_scoped_acquire_local() + 25 (internals.h:264)
8   dawdreamer.so                 	0x000000010f706e65 pybind11::detail::get_internals()::gil_scoped_acquire_local::gil_scoped_acquire_local() + 21 (internals.h:264)
9   dawdreamer.so                 	0x000000010f70681d pybind11::detail::get_internals() + 93 (internals.h:267)
10  dawdreamer.so                 	0x000000010f7c3612 PyInit_dawdreamer + 162 (source.cpp:4)
11  python                        	0x000000010ecb42f5 _PyImport_LoadDynamicModuleWithSpec + 565
...

It appears that pybind11 is (maybe) trying to reference an uninitialized Python GIL? Any suggestions on debugging this issue are welcome!

woodshop avatar Feb 05 '21 21:02 woodshop

Hi! I'm very glad to hear about Linux.

For Mac, could you examine your Xcode files and see if they're any different? https://github.com/DBraun/DawDreamer/blob/master/Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj Look for references to Python. I'd like to make sure that those paths make sense and that Xcode isn't falling back on something that works at compilation but not runtime.

DBraun avatar Feb 05 '21 23:02 DBraun

One more thing is that maybe you're using Python that didn't come from homebrew. I only tested with homebrew, not conda/miniconda etc.

DBraun avatar Feb 05 '21 23:02 DBraun

Thanks for the suggestions @DBraun.

❌ For Mac, could you examine your Xcode files and see if they're any different? ➡️ There are no unexpected paths in the generated Xcode file

✅ One more thing is that maybe you're using Python that didn't come from homebrew. ➡️ This is very surprising to me, but compiling/linking using Python3.8 installed via brew and pyenv works, whereas doing so with conda does not work. 🤷

Since I'm able to install following the exact given directions, this is probably not a dawdreamer bug. But I'd be very curious to know if anyone has an explanation as to why using a conda-installed version of python fails on my Mac.

woodshop avatar Feb 08 '21 15:02 woodshop

I'm not the biggest fan of brew myself. I only used it because RenderMan previously used it. Maybe these lines indicate something, but it's similar to what you scoped out in the Xcode file.

DBraun avatar Feb 08 '21 18:02 DBraun

I have the same issue on my Mac. MacOS 11.6.3 conda 4.13.0 python 3.9.7

Centauria avatar Sep 08 '22 09:09 Centauria