I had some time to mess with this today, so I grabbed the PDBs from extras/, the source from git and generated the sipped code. Ran to the seg fault, popped into Visual Studio and here’s what I found, along with my naive interpretation (I’m completely ignorant of what this should look like, but some of the pieces look very suspicious).
The event object appears to be correct at the bottom of call stack (shown below), in CallEventHandler, but after it has passed through the EventThunker (where it’s invisible, “optimized away”) and python38 dll, it is mangled in GetEventObject.
Here’s the good version of the event object from CallEventHandler, note the value of m_eventType is 10045 as expected.
- event {m_clickCount=-1 m_wheelAxis=wxMOUSE_WHEEL_VERTICAL (0) m_wheelRotation=-120 ...} wxEvent & {wxmsw314u_core_vc140_x64.dll!wxMouseEvent}
+ [wxMouseEvent] {m_clickCount=-1 m_wheelAxis=wxMOUSE_WHEEL_VERTICAL (0) m_wheelRotation=-120 ...} wxmsw314u_core_vc140_x64.dll!wxMouseEvent
+ wxObject {m_refData=0x0000000000000000 <NULL> } wxObject
+ m_eventObject 0x0000025242b2c9b0 {m_type=wxGridWindowNormal (0) } wxObject * {wxmsw314u_core_vc140_x64.dll!wxGridWindow}
m_eventType 10045 int
m_timeStamp 701971546 long
m_id -31726 int
+ m_callbackUserData 0x00000252519b2180 {m_func=0x00000252480cbac0 {ob_refcnt=1 ob_type=0x00007ff91ddd95b0 {python38.dll!_typeobject PyMethod_Type} {...} } } wxObject * {_core.cp38-win_amd64.pyd!wxPyCallback}
+ m_handlerToProcessOnlyIn 0x0000000000000000 <NULL> wxEvtHandler *
m_propagationLevel 0 int
+ m_propagatedFrom 0x0000000000000000 <NULL> wxEvtHandler *
m_skipped false bool
m_isCommandEvent false bool
m_wasProcessed true bool
m_willBeProcessedAgain false bool
Now here is what I believe to be the same object after passing through EventThunker and a bunch of CPython library calls. m_eventType is wacky and the eventObject pointer is clearly out into space.
This happens when I roll the scroll wheel past the bottom of the window, speed doesn’t seem to matter and it’s reproducible, but not cleanly (you just need to start scrolling the window up and down until it happens, sometimes right away, sometimes it takes 20-30 tries).
- sipCpp 0x0000006e0bbee540 {m_eventObject=0x0000000000000466 {m_refData=??? } m_eventType=49087590 m_timeStamp=...} const wxEvent *
+ wxObject {m_refData=0x00000000ff880000 {m_count=??? } } wxObject
+ m_eventObject 0x0000000000000466 {m_refData=??? } wxObject *
m_eventType 49087590 int
m_timeStamp 0 long
m_id 0 int
+ m_callbackUserData 0x0000000000000084 {m_refData=??? } wxObject *
+ m_handlerToProcessOnlyIn 0x000000140000004d {m_nextHandler=??? m_previousHandler=??? m_dynamicEvents=??? ...} wxEvtHandler *
m_propagationLevel 0 int
+ m_propagatedFrom 0x0000025242b2c9b0 {m_type=wxGridWindowNormal (0) } wxEvtHandler * {wxmsw314u_core_vc140_x64.dll!wxGridWindow}
m_skipped true (254) bool
m_isCommandEvent true (255) bool
m_wasProcessed true (255) bool
m_willBeProcessedAgain true (255) bool
The call stack near the crash point (with both ends trimmed off as they seemed too early or to late to help).
_core.cp38-win_amd64.pyd!meth_wxEvent_GetEventObject(_object * sipSelf, _object * sipArgs) Line 88
at c:\projects\bb2\dist-win64-py38\build\sip\cpp\sip_corewxevent.cpp(88)
python38.dll!cfunction_call_varargs(_object * func, _object * args, _object * kwargs) Line 757
at c:\a\27\s\objects\call.c(757)
python38.dll!_PyObject_MakeTpCall(_object * callable, _object * const * args, __int64 nargs, _object * keywords) Line 160
at c:\a\27\s\objects\call.c(160)
python38.dll!property_descr_get(_object * self, _object * obj, _object * type) Line 1495
at c:\a\27\s\objects\descrobject.c(1495)
python38.dll!_PyObject_GenericGetAttrWithDict(_object * obj, _object * name, _object * dict, int suppress) Line 1251
at c:\a\27\s\objects\object.c(1251)
[Inline Frame] python38.dll!PyObject_GenericGetAttr(_object *) Line 1332
at c:\a\27\s\objects\object.c(1332)
python38.dll!PyObject_GetAttr(_object * v, _object * name) Line 949
at c:\a\27\s\objects\object.c(949)
python38.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 2967
at c:\a\27\s\python\ceval.c(2967)
[Inline Frame] python38.dll!PyEval_EvalFrameEx(_frame *) Line 741
at c:\a\27\s\python\ceval.c(741)
[Inline Frame] python38.dll!function_code_fastcall(PyCodeObject * args, _object * const *) Line 283
at c:\a\27\s\objects\call.c(283)
python38.dll!_PyFunction_Vectorcall(_object * func, _object * const * stack, unsigned __int64 nargsf, _object * kwnames) Line 410
at c:\a\27\s\objects\call.c(410)
[Inline Frame] python38.dll!_PyObject_Vectorcall(_object * nargsf, _object * const *) Line 127
at c:\a\27\s\include\cpython\abstract.h(127)
python38.dll!method_vectorcall(_object * method, _object * const * args, unsigned __int64 nargsf, _object * kwnames) Line 89
at c:\a\27\s\objects\classobject.c(89)
python38.dll!PyVectorcall_Call(_object * callable, _object * tuple, _object * kwargs) Line 199
at c:\a\27\s\objects\call.c(199)
python38.dll!PyObject_Call(_object * callable, _object * args, _object * kwargs) Line 251
at c:\a\27\s\objects\call.c(251)
_core.cp38-win_amd64.pyd!wxPyCallback::EventThunker(wxEvent & event) Line 72
at c:\projects\bb2\dist-win64-py38\build\sip\cpp\sip_corewxevthandler.cpp(72)
wxbase314u_vc140_x64.dll!wxAppConsoleBase::CallEventHandler(wxEvtHandler * handler, wxEventFunctor & functor, wxEvent & event) Line 670
at c:\projects\bb2\dist-win64-py38\build\ext\wxwidgets\src\common\appbase.cpp(670)