Using latest cothread on python3.11 with pyqt results in segfault
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- desktop-dev
Research direction
Start by reproducing the Python 3.11 PyQt segfault with cothread.iqt(run_exec=True), then inspect input_hook.py around iqt(), QApplication.exec(), cothread.Spawn(), and the immediate cothread.Yield(). Compare the run_exec=False and removed-Yield workarounds; done means the documented execution and yield paths no longer segfault.
Written by the indexing model from the issue text.
Description
Calling this: cothread.iqt(run_exec=True)
Results in a segfault.
UPDATE 2
Im seeing some issues with following the advice in update 1, things not working the way they used too.
UPDATE 1
For the first fix below, QApplication.exec() should be spawned as a cothread, not called directly. Such as:
cothread.Spawn(_qapp.exec)This works fine, but if you do any future yields or call any cothread functions which yield from the main thread it will segfault.
So this works:
def ticker(): while True: cothread.Sleep(1) print("*** --------------------------------------------- tick") cothread.Spawn(_qapp.exec) cothread.Spawn(ticker) cothread.WaitForQuit()But this segfaults:
cothread.Spawn(_qapp.exec) cothread.Yield() cothread.WaitForQuit()This is okayish as you typically spawning the exec thread is the last thing you do before running cothread.WaitForQuit().
But obviously the root issue needs to be fixed.The second fix below suffers from the same issue.
Quick fixes:
-
A quick fix can be made by either setting run_exec=False and calling QApplication.exec() manually.
-
Or by removing the
cothread.Yield()called immediately aftercothread.Spawn(getattr(_qapp, exec_name), stack_size = QT_STACK_SIZE)in the iqt() function in input_hook.py
I don't yet understand the root cause of this issue, but will continue investigating.
- Dominant language
- C
- Stars
- 13
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
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.
More from DiamondLightSource/cothread
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DiamondLightSource/cothread#78 · 2 comments ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
DiamondLightSource/cothread#73 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DiamondLightSource/cothread#68 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
DiamondLightSource/cothread#67 · 2 comments ·
All issues in DiamondLightSource/cothread
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·