-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookups usiing requests crash on Ansible Core 2.18 on macOS #1219
Comments
I'm not sure this is a Mitogen specific bug. I get crashes across multiple versions of plain Ansible (without Mitogen), and standalone Pythons from uv/tox-uv https://github.com/moreati/mitogen-issue-1219.
➜ mitogen-issue-1219 git:(main) uname -a
Darwin kintha 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm64
➜ mitogen-issue-1219 git:(main) tox --version
4.23.0 from /Users/alex/.local/share/uv/tools/tox/lib/python3.13/site-packages/tox/__init__.py
registered plugins:
tox-uv-1.15.0 at /Users/alex/.local/share/uv/tools/tox/lib/python3.13/site-packages/tox_uv/plugin.py with uv==0.4.25 ➜ mitogen-issue-1219 tox
py3.11-ansible8-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60235]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60235]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.11-ansible8-linear: exit 1 (0.48 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60232
py3.11-ansible8-linear: FAIL ✖ in 0.48 seconds
py3.11-ansible9-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60238]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60238]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.11-ansible9-linear: exit 1 (0.43 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60236
py3.11-ansible9-linear: FAIL ✖ in 0.43 seconds
py3.11-ansible10-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60243]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60243]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.11-ansible10-linear: exit 1 (0.41 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60241
py3.11-ansible10-linear: FAIL ✖ in 0.41 seconds
py3.11-ansible11-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60246]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60246]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.11-ansible11-linear: exit 1 (0.41 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60244
py3.11-ansible11-linear: FAIL ✖ in 0.41 seconds
py3.12-ansible8-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60250]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60250]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.12-ansible8-linear: exit 1 (0.47 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60247
py3.12-ansible8-linear: FAIL ✖ in 0.48 seconds
py3.12-ansible9-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60253]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60253]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.12-ansible9-linear: exit 1 (0.42 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60251
py3.12-ansible9-linear: FAIL ✖ in 0.43 seconds
py3.12-ansible10-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60256]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60256]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.12-ansible10-linear: exit 1 (0.42 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60254
py3.12-ansible10-linear: FAIL ✖ in 0.42 seconds
py3.12-ansible11-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60259]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60259]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.12-ansible11-linear: exit 1 (0.42 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60257
py3.12-ansible11-linear: FAIL ✖ in 0.43 seconds
py3.13-ansible8-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60263]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60263]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.13-ansible8-linear: exit 1 (0.46 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60260
py3.13-ansible8-linear: FAIL ✖ in 0.46 seconds
py3.13-ansible9-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60266]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60266]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.13-ansible9-linear: exit 1 (0.44 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60264
py3.13-ansible9-linear: FAIL ✖ in 0.44 seconds
py3.13-ansible10-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60269]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60269]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.13-ansible10-linear: exit 1 (0.43 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60267
py3.13-ansible10-linear: FAIL ✖ in 0.44 seconds
py3.13-ansible11-linear: commands[0]> ansible-playbook playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
objc[60272]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
objc[60272]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state
py3.13-ansible11-linear: exit 1 (0.43 seconds) /Users/alex/src/mitogen-issue-1219> ansible-playbook playbook.yml pid=60270
py3.11-ansible8-linear: FAIL code 1 (0.48=setup[0.00]+cmd[0.48] seconds)
py3.11-ansible9-linear: FAIL code 1 (0.43=setup[0.00]+cmd[0.43] seconds)
py3.11-ansible10-linear: FAIL code 1 (0.41=setup[0.00]+cmd[0.41] seconds)
py3.11-ansible11-linear: FAIL code 1 (0.41=setup[0.00]+cmd[0.41] seconds)
py3.12-ansible8-linear: FAIL code 1 (0.48=setup[0.00]+cmd[0.47] seconds)
py3.12-ansible9-linear: FAIL code 1 (0.43=setup[0.00]+cmd[0.42] seconds)
py3.12-ansible10-linear: FAIL code 1 (0.42=setup[0.00]+cmd[0.42] seconds)
py3.12-ansible11-linear: FAIL code 1 (0.43=setup[0.00]+cmd[0.42] seconds)
py3.13-ansible8-linear: FAIL code 1 (0.46=setup[0.00]+cmd[0.46] seconds)
py3.13-ansible9-linear: FAIL code 1 (0.44=setup[0.00]+cmd[0.44] seconds)
py3.13-ansible10-linear: FAIL code 1 (0.44=setup[0.00]+cmd[0.43] seconds)
py3.13-ansible11-linear: FAIL code 1 (0.43=setup[0.00]+cmd[0.43] seconds)
evaluation failed :( (5.31 seconds) I also see it with Python 3.9 (as installed by Apple dev tools) and Ansible 8.7 ➜ mitogen-issue-1219 v39/bin/pip install ansible requests
...
Successfully installed MarkupSafe-3.0.2 PyYAML-6.0.2 ansible-8.7.0 ansible-core-2.15.13 certifi-2024.12.14 cffi-1.17.1 charset-normalizer-3.4.1 cryptography-44.0.0 idna-3.10 importlib-resources-5.0.7 jinja2-3.1.5 packaging-24.2 pycparser-2.22 requests-2.32.3 resolvelib-1.0.1 urllib3-2.3.0
➜ mitogen-issue-1219 ANSIBLE_LOOKUP_PLUGINS=plugins/lookup v39/bin/ansible-playbook -i inventory.yml playbook.yml
PLAY [Use requests_example lookup] ********************************************************************************************************************************************************************************************
TASK [debug] ******************************************************************************************************************************************************************************************************************
/Users/alex/src/mitogen-issue-1219/v39/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
warnings.warn(
objc[60086]: +[NSMutableString initialize] may have been in progress in another thread when fork() was called.
objc[60086]: +[NSMutableString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
ERROR! A worker was found in a dead state |
I agree there are wider problems with Mitogen on macOS, particularly wrt Since Python 3.8
|
Those fails are usually solvable by exporting In this case it doesn't seem to help unfortunately. |
Looks like Ansible Core 2.18 has messed something with how lookups are done. A single
reqests.get
call is enough to kill the thread on macOS (Linux seems to be alright). Everything works fine on 2.17.Note that 2.18 seems to mess with interpreter selection in general, I had to update/remove shebangs in some modules to make it usable even without mitogen. I wouldn't be surprised if that's related. Lookup is called in a playbook targetting localhost - in the past it was running with
ansible_python_interpreter: "{{ ansible_playbook_python }}"
, tried without it and withinterpreter_python
set to the same value, no difference.OBJC_DISABLE_INITIALIZE_FORK_SAFETY
doesn't seem to change anything either.Note that outside of lookup requests work just fine.
While issue was found usiing Hashivault's lookup plugin, I've been able to reproduce it with a simple requests call after investigating original stacktrace for exact failure location (stacktrace in later section might have slightly mismatched line number for the call, I've removed some docstrings).
Environment
Ansible Config dump
Additional modules
From Galaxy:
From PyPI:
Ansiible run logs
The text was updated successfully, but these errors were encountered: