jupyter / qtconsole

Jupyter Qt Console
https://qtconsole.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
413 stars 199 forks source link

Segfault on import running against Qt 6.7 on 64 bit Windows 11 w/ python 3.12 #605

Open jpieper opened 4 months ago

jpieper commented 4 months ago

After updating a 64 bit Windows 11 installation to PySide 6.7, importing qtconsole triggers a segfault. Switching back and forth between 6.6.1 and 6.7 causes it to happen or not. A minimal test case is:

import PySide6
import qtconsole
from qtconsole.history_console_widget import HistoryConsoleWidget

I have reproduced with python 3.12.1 and python 3.12.3 releases as downloaded from python.org. python 3.11.9 does not seem to have the problem and works as expected.

I'm testing with qtconsole 56e5a5ec5cfccf5afd098fe8bb5b2c558a1dc8f9 now, but the same problem occurred with the 5.5.2 release. I installed python debug symbols and got the following backtrace, although it isn't terribly meaningful to me.

    ntdll.dll!00007ff87023c0f2()    Unknown
    ntdll.dll!00007ff8702451ca()    Unknown
    ntdll.dll!00007ff8702454aa()    Unknown
    ntdll.dll!00007ff8702514a5()    Unknown
    ntdll.dll!00007ff8701dc418()    Unknown
    ntdll.dll!00007ff87016ab11()    Unknown
>   ucrtbase.dll!00007ff86dc3364b() Unknown
    [Inline Frame] python312.dll!_PyMem_RawFree(void *) Line 73 C
    [Inline Frame] python312.dll!PyMem_RawFree(void *) Line 685 C
    python312.dll!_PyObject_Free(void * ctx, void * p) Line 1854    C
    [Inline Frame] python312.dll!PyMem_Free(void *) Line 732    C
    [Inline Frame] python312.dll!data_stack_dealloc(SRE_STATE *) Line 194   C
    [Inline Frame] python312.dll!state_fini(SRE_STATE *) Line 484   C
    [Inline Frame] python312.dll!_sre_SRE_Pattern_match_impl(PatternObject *) Line 661  C
    python312.dll!_sre_SRE_Pattern_match(PatternObject * self, _typeobject * cls, _object * const * args, __int64 nargs, _object * kwnames) Line 253    C
    python312.dll!method_vectorcall_FASTCALL_KEYWORDS_METHOD(_object * func, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 390   C
    python312.dll!_PyObject_VectorcallTstate(_ts * tstate, _object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 92  C
    python312.dll!PyObject_Vectorcall(_object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 327  C
    python312.dll!_PyEval_EvalFrameDefault(_ts * tstate, _PyInterpreterFrame * frame, int throwflag) Line 2706  C
    [Inline Frame] python312.dll!_PyEval_EvalFrame(_ts *) Line 89   C
    [Inline Frame] python312.dll!_PyEval_Vector(_ts *) Line 1683    C
    python312.dll!_PyFunction_Vectorcall(_object * func, _object * const * stack, unsigned __int64 nargsf, _object * kwnames) Line 419  C
    python312.dll!_PyObject_VectorcallTstate(_ts * tstate, _object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 92  C
    python312.dll!object_vacall(_ts * tstate, _object * base, _object * callable, char * vargs) Line 850    C
    python312.dll!PyObject_CallFunctionObjArgs(_object * callable, ...) Line 961    C
    shiboken6.abi3.dll!00007fffb3201969()   Unknown
    python312.dll!cfunction_call(_object * func, _object * args, _object * kwargs) Line 550 C
    [Inline Frame] python312.dll!_PyObject_MakeTpCall(_ts * keywords, _object *) Line 240   C
    python312.dll!_PyObject_VectorcallTstate(_ts * tstate, _object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 90  C
    [Inline Frame] python312.dll!_PyObject_FastCallTstate(_ts *) Line 116   C
    python312.dll!_PyObject_FastCall(_object * func, _object * const * args, __int64 nargs) Line 335    C
    python312.dll!import_name(_ts * tstate, _PyInterpreterFrame * frame, _object * name, _object * fromlist, _object * level) Line 2497 C
    python312.dll!_PyEval_EvalFrameDefault(_ts * tstate, _PyInterpreterFrame * frame, int throwflag) Line 2997  C
    [Inline Frame] python312.dll!_PyEval_EvalFrame(_ts *) Line 89   C
    python312.dll!_PyEval_Vector(_ts * tstate, PyFunctionObject * func, _object * locals, _object * const * args, unsigned __int64 argcount, _object * kwnames) Line 1684   C
    python312.dll!PyEval_EvalCode(_object * co, _object * globals, _object * locals) Line 579   C
    python312.dll!builtin_exec_impl(_object * source, _object * globals, _object * locals, _object * closure, _object *) Line 1127  C
    python312.dll!builtin_exec(_object * module, _object * const * args, __int64 nargs, _object * kwnames) Line 586 C
    python312.dll!cfunction_vectorcall_FASTCALL_KEYWORDS(_object * func, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 439   C
    python312.dll!_PyVectorcall_Call(_ts * tstate, _object *(*)(_object *, _object * const *, unsigned __int64, _object *) func, _object * callable, _object * tuple, _object * kwargs) Line 288    C
    [Inline Frame] python312.dll!_PyObject_Call(_ts *) Line 354 C
    python312.dll!PyObject_Call(_object * callable, _object * args, _object * kwargs) Line 379  C
    python312.dll!_PyEval_EvalFrameDefault(_ts * tstate, _PyInterpreterFrame * frame, int throwflag) Line 3254  C
    [Inline Frame] python312.dll!_PyEval_EvalFrame(_ts *) Line 89   C
    [Inline Frame] python312.dll!_PyEval_Vector(_ts *) Line 1683    C
    python312.dll!_PyFunction_Vectorcall(_object * func, _object * const * stack, unsigned __int64 nargsf, _object * kwnames) Line 419  C
    python312.dll!_PyObject_VectorcallTstate(_ts * tstate, _object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 92  C
    python312.dll!object_vacall(_ts * tstate, _object * base, _object * callable, char * vargs) Line 850    C
    python312.dll!PyObject_CallMethodObjArgs(_object * obj, _object * name, ...) Line 914   C
    python312.dll!import_find_and_load(_ts * tstate, _object * abs_name) Line 2779  C
    python312.dll!PyImport_ImportModuleLevelObject(_object * name, _object * globals, _object * locals, _object * fromlist, int level) Line 2862    C
    [Inline Frame] python312.dll!builtin___import___impl(_object *) Line 275    C
    python312.dll!builtin___import__(_object * module, _object * const * args, __int64 nargs, _object * kwnames) Line 107   C
    python312.dll!cfunction_vectorcall_FASTCALL_KEYWORDS(_object * func, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 439   C
    python312.dll!_PyVectorcall_Call(_ts * tstate, _object *(*)(_object *, _object * const *, unsigned __int64, _object *) func, _object * callable, _object * tuple, _object * kwargs) Line 288    C
    [Inline Frame] python312.dll!_PyObject_Call(_ts *) Line 354 C
    python312.dll!PyObject_Call(_object * callable, _object * args, _object * kwargs) Line 379  C
    shiboken6.abi3.dll!00007fffb320755a()   Unknown
    python312.dll!cfunction_call(_object * func, _object * args, _object * kwargs) Line 550 C
    [Inline Frame] python312.dll!_PyObject_Call(_ts *) Line 367 C
    python312.dll!PyObject_Call(_object * callable, _object * args, _object * kwargs) Line 379  C
    shiboken6.abi3.dll!00007fffb320194a()   Unknown
    python312.dll!cfunction_call(_object * func, _object * args, _object * kwargs) Line 550 C
    [Inline Frame] python312.dll!_PyObject_MakeTpCall(_ts * keywords, _object *) Line 240   C
    python312.dll!_PyObject_VectorcallTstate(_ts * tstate, _object * callable, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 90  C
    [Inline Frame] python312.dll!_PyObject_FastCallTstate(_ts *) Line 116   C
    python312.dll!_PyObject_FastCall(_object * func, _object * const * args, __int64 nargs) Line 335    C
    python312.dll!import_name(_ts * tstate, _PyInterpreterFrame * frame, _object * name, _object * fromlist, _object * level) Line 2497 C
    python312.dll!_PyEval_EvalFrameDefault(_ts * tstate, _PyInterpreterFrame * frame, int throwflag) Line 2997  C
    [Inline Frame] python312.dll!_PyEval_EvalFrame(_ts *) Line 89   C
    python312.dll!_PyEval_Vector(_ts * tstate, PyFunctionObject * func, _object * locals, _object * const * args, unsigned __int64 argcount, _object * kwnames) Line 1684   C
    python312.dll!PyEval_EvalCode(_object * co, _object * globals, _object * locals) Line 579   C
    python312.dll!run_eval_code_obj(_ts * tstate, PyCodeObject * co, _object * globals, _object * locals) Line 1723 C
    python312.dll!run_mod(_mod * mod, _object * filename, _object * globals, _object * locals, PyCompilerFlags * flags, _arena * arena) Line 1744   C
    python312.dll!PyRun_InteractiveOneObjectEx(_iobuf * fp, _object * filename, PyCompilerFlags * flags) Line 261   C
    python312.dll!_PyRun_InteractiveLoopObject(_iobuf * fp, _object * filename, PyCompilerFlags * flags) Line 137   C
    python312.dll!_PyRun_AnyFileObject(_iobuf * fp, _object * filename, int closeit, PyCompilerFlags * flags) Line 72   C
    python312.dll!PyRun_AnyFileExFlags(_iobuf * fp, const char * filename, int closeit, PyCompilerFlags * flags) Line 104   C
    python312.dll!pymain_run_stdin(PyConfig * config) Line 521  C
    python312.dll!pymain_run_python(int * exitcode) Line 632    C
    python312.dll!Py_RunMain() Line 711 C
    python312.dll!Py_Main(int argc, wchar_t * * argv) Line 752  C
    python.exe!00007ff72c3c1230()   Unknown
    kernel32.dll!00007ff86fb1257d() Unknown
    ntdll.dll!00007ff87018aa48()    Unknown
ccordoba12 commented 4 months ago

I think this is caused by https://github.com/spyder-ide/qtpy/issues/480. The problem is PySide 6.7 broke star imports (i.e imports of the form from foo import *), which are used everywhere in Qtpy. And Qtpy is the abstraction layer used in Qtconsole to support PySide and PyQt in a single codebase.

So, for now please keep using PySide 6.6.1.

jpieper commented 4 months ago

Great, thanks! Sticking with 6.6.1 is easy enough. Feel free to close this if you don't want to bother tracking it separately!

ccordoba12 commented 4 months ago

I'll leave it open in case other people face the same problem so they can easily find the solution.