Fatal Python Error pyOCD crashes Python when used in thread on macOS
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 560
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 3
Description
pyOCD debug probe discovery crashes Python when used in threading.Thread on MacOS
Tested with Python 3.8 and 3.11.2 with pyOCD 0.34.3
Code snippet below:
from threading import Thread
from pyocd.core.helpers import ConnectHelper
def task():
probes = ConnectHelper.get_all_connected_probes()
print(probes)
thread = Thread(target=task)
thread.start()
thread.join()
Application crashes during closing in weakref module when releasing memory.
Fatal Python error: Illegal instructionCurrent thread 0x00000001142c2600 (most recent call first):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/weakref.py", line 591 in call
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/weakref.py", line 667 in _exitfunc
The only suspicious code lies in the pyocd/core/session.py
Session._current_session = weakref.ref(self)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash on macOS using the threaded code snippet with Python 3.8 or 3.11.2 and pyOCD 0.34.3. Start by inspecting pyocd/core/session.py, especially Session._current_session and its weakref usage. Done means probe discovery from a threading.Thread no longer causes the fatal shutdown error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100