Assertion Error in threading module when finalize_interpreter
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Reproducible example code
Standalone setup is provided here : https://gist.github.com/abidrahmank/1ec549e13f600cd11eb70561c9223210
Just call make
Issue description
I have following workflow :
-
I have a C library (crashloader.cpp) which will load other shared library plugins (threadcrash.cpp) and execute functions in that.
-
Plugin libraries typically contains a function that creates an object (goo), execute it (execgoo) and delete it (delgoo).
-
In my case, plugin embeds a Python script and execute it. So I initialize interpreter in object constructor and finalize it in destructor.
Issue : Everything works fine if I call exec in the same thread as creating the object. But the moment I call exec in a separate thread (which is my actual use case), I get following Assertion Error.
Exception ignored in: <module 'threading' from '......../lib/python3.6/threading.py'>
Traceback (most recent call last):
File "......./lib/python3.6/threading.py", line 1299, in _shutdown
assert tlock.locked()
AssertionError:
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
Start with the standalone setup linked in the issue and run make to reproduce the assertion. Read crashloader.cpp and threadcrash.cpp, then trace the separate-thread execution through Python 3.6's threading.py _shutdown at line 1299. Done means the reproducible workflow no longer raises the assertion during interpreter finalization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100