Skip to content

Using latest cothread on python3.11 with pyqt results in segfault #75

@ptsOSL

Description

@ptsOSL

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 after cothread.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions