Crash in Window_ReleaseMouse

This is kind of a combined wxwidgets/wxpython question…

My app has been crashing with the following stack trace (OSX, but I don’t think this is OSX specific):

0 libwx_macu-2.8.0.dylib 0x013b5e4d wxWindowBase::ReleaseMouse() + 61

1 core.so 0x01044266 _wrap_Window_ReleaseMouse + 86 (_core_wrap.cpp:39363)

2 org.python.python 0x000c1d6e PyEval_EvalFrameEx + 19502

3 org.python.python 0x000c3e9d PyEval_EvalCodeEx + 2109

4…rest of stack trace clipped

So, I looked at the source code in wxwidgets for
wxWindowBase::ReleaseMouse() (2.8.11.0), and added this assert at the top, which is present in the 2.9.1 tree of wxwidgets, hoping it would fix the problem. Specifically, I put this in src/common/wincmn.cpp, at the top of ReleaseMouse:

// DGH ADD FROM 2.9.1.1

wxASSERT_MSG( ms_winCaptureCurrent == this, “attempt to release mouse, but this window hasn’t captured it” );

I also placed if checks around all pointer usages in that routine, but I don’t think any of them are getting triggered, but I can’t say for sure. App still crashes, but with a slightly different stack trace. It looks like it got past the ReleaseMouse routine, but now dies in the swig wrapper.

0 org.python.python 0x00041c9a int__format__ + 266

1 core.so 0x01044266 _wrap_Window_ReleaseMouse + 86 (_core_wrap.cpp:39363)

2 org.python.python 0x000c1d6e PyEval_EvalFrameEx + 19502

3 org.python.python 0x000c3e9d PyEval_EvalCodeEx + 2109

4…rest of stack trace clipped.

I don’t see a int__format__ function or anything inside
_wrap_Window_ReleaseMouse…so do these little tidbits of information mean anything to anyone? I’m stuck, and hoping that some little glimmer of information might lead to me figuring this out.

This is kind of a combined wxwidgets/wxpython question...

My app has been crashing with the following stack trace (OSX, but I
don't think this is OSX specific):

0 libwx_macu-2.8.0.dylib 0x013b5e4d wxWindowBase::ReleaseMouse() + 61
1 _core_.so 0x01044266 _wrap_Window_ReleaseMouse + 86 (_core_wrap.cpp:39363)
2 org.python.python 0x000c1d6e PyEval_EvalFrameEx + 19502
3 org.python.python 0x000c3e9d PyEval_EvalCodeEx + 2109
4...rest of stack trace clipped

So, I looked at the source code in wxwidgets for
wxWindowBase::ReleaseMouse() (2.8.11.0), and added this assert at the
top, which is present in the 2.9.1 tree of wxwidgets, hoping it would
fix the problem. Specifically, I put this in src/common/wincmn.cpp, at
the top of ReleaseMouse:

// DGH ADD FROM 2.9.1.1
wxASSERT_MSG( ms_winCaptureCurrent == this, "attempt to release mouse,
but this window hasn't captured it" );

I also placed if checks around all pointer usages in that routine, but I
don't think any of them are getting triggered, but I can't say for sure.
App still crashes, but with a slightly different stack trace. It looks
like it got past the ReleaseMouse routine, but now dies in the swig wrapper.

0 org.python.python 0x00041c9a int__format__ + 266
1 _core_.so 0x01044266 _wrap_Window_ReleaseMouse + 86 (_core_wrap.cpp:39363)
2 org.python.python 0x000c1d6e PyEval_EvalFrameEx + 19502
3 org.python.python 0x000c3e9d PyEval_EvalCodeEx + 2109
4.....rest of stack trace clipped.

I don't see a int__format__ function or anything inside
_wrap_Window_ReleaseMouse...

It looks to me like it is executing in the Python framework at that point...

so do these little tidbits of information
mean anything to anyone? I'm stuck, and hoping that some little glimmer
of information might lead to me figuring this out.

...but I wouldn't be too surprised if the real problem were someplace else and it is just not manifesting itself until this point in the execution. Is there anything special or unusual going on in the application just before the crash? Does it help if you avoid calling ReleaseMouse like the following or does the crash still happen in some other way or place?

  if self and self.HasCapture():
    self.ReleaseMouse()

···

On 1/6/11 9:19 AM, dhyams wrote:

--
Robin Dunn
Software Craftsman

It only looks like it make it back to framework with my hacked version of ReleaseMouse(), though…not sure what that implies.

It’s really matplotlib that’s calling the capture and release functions. Grepping through the code, they already use the “if self.HasCapture()”

conditional before calling ReleaseMouse (backends_wx.py), but they do not use the corresponding guard when calling CaptureMouse(). I’ll put those in and see if makes any difference.

There’s really nothing unusual going on before the crash; I’m just using the mouse rotations, zooms, etc. in a 3D plot.

This related, I suppose, and demonstrates that something is going wrong in wxwidget’s capture stack possibly?

This snippet is from matplotlib:

def _onMiddleButtonUp(self, evt):

“”“End measuring on an axis.”""

x = evt.GetX()

y = self.figure.bbox.height - evt.GetY()

#print ‘release button’, 1

evt.Skip()

if self.HasCapture(): self.ReleaseMouse()

FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)

Notice the “if HasCapture, Release”. I can very reliably (by right clicking on a 3D plot to post a popup menu of my own, and then middle clicking off of it) generate the following exception:

Traceback (most recent call last):

File “C:\Python26\lib\site-packages\matplotlib\backends\backend_wx.py”, line 1310, in _onMiddleButtonUp

if self.HasCapture(): self.ReleaseMouse()

File “C:\Python26\lib\site-packages\wx-2.9.1-msw\wx_core.py”, line 10494, in ReleaseMouse

return core.Window_ReleaseMouse(*args, **kwargs)

PyAssertionError: C++ assertion “ms_winCaptureCurrent == this” failed at …\src\common\wincmn.cpp(2884) in wxWindowBase::ReleaseMouse(): attempt to release mouse, but this window hasn’t captured it

So HasCapture() thinks that the window has the capture, but on releasing the capture, we find out that we don’t?

Sorry, didn’t post platform or version of the last post. Windows, wxPython 2.9.1.1.

El 10/01/2011 16:58, dhyams escribi�:

This related, I suppose, and demonstrates that something is going wrong
in wxwidget's capture stack possibly?

This snippet is from matplotlib:

def _onMiddleButtonUp(self, evt):
"""End measuring on an axis."""
x = evt.GetX()
y = self.figure.bbox.height - evt.GetY()
#print 'release button', 1
evt.Skip()
if self.HasCapture(): self.ReleaseMouse()
FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)

Notice the "if HasCapture, Release". I can very reliably (by right
clicking on a 3D plot to post a popup menu of my own, and then middle
clicking off of it) generate the following exception:

Traceback (most recent call last):
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1310, in _onMiddleButtonUp
if self.HasCapture(): self.ReleaseMouse()
File "C:\Python26\lib\site-packages\wx-2.9.1-msw\wx\_core.py", line
10494, in ReleaseMouse
return _core_.Window_ReleaseMouse(*args, **kwargs)
PyAssertionError: C++ assertion "ms_winCaptureCurrent == this" failed at
..\..\src\common\wincmn.cpp(2884) in wxWindowBase::ReleaseMouse():
attempt to release mouse, but this window hasn't captured it

So HasCapture() thinks that the window has the capture, but on releasing
the capture, we find out that we don't?

Perhaps is a silly action, but, are you try to put evt.Skip() at the end of the function instead before of releasemouse?

···

--
Oswaldo Hern�ndez

Can you reproduce this in a small app that doesn't need 3rd party libraries?

···

On 1/10/11 7:58 AM, dhyams wrote:

This related, I suppose, and demonstrates that something is going wrong
in wxwidget's capture stack possibly?

This snippet is from matplotlib:

def _onMiddleButtonUp(self, evt):
"""End measuring on an axis."""
x = evt.GetX()
y = self.figure.bbox.height - evt.GetY()
#print 'release button', 1
evt.Skip()
if self.HasCapture(): self.ReleaseMouse()
FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)

Notice the "if HasCapture, Release". I can very reliably (by right
clicking on a 3D plot to post a popup menu of my own, and then middle
clicking off of it) generate the following exception:

Traceback (most recent call last):
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1310, in _onMiddleButtonUp
if self.HasCapture(): self.ReleaseMouse()
File "C:\Python26\lib\site-packages\wx-2.9.1-msw\wx\_core.py", line
10494, in ReleaseMouse
return _core_.Window_ReleaseMouse(*args, **kwargs)
PyAssertionError: C++ assertion "ms_winCaptureCurrent == this" failed at
..\..\src\common\wincmn.cpp(2884) in wxWindowBase::ReleaseMouse():
attempt to release mouse, but this window hasn't captured it

So HasCapture() thinks that the window has the capture, but on releasing
the capture, we find out that we don't?

--
Robin Dunn
Software Craftsman

All Skip() does it set a flag, and that flag is not checked until after the event handler returns, so where Skip is called in the event handler makes no difference.

···

On 1/10/11 9:35 AM, Oswaldo Hern�ndez wrote:

Perhaps is a silly action, but, are you try to put evt.Skip() at the end
of the function instead before of releasemouse?

--
Robin Dunn
Software Craftsman

I wish I could; have not been able to yet.

···

On Mon, Jan 10, 2011 at 2:13 PM, Robin Dunn robin@alldunn.com wrote:

On 1/10/11 7:58 AM, dhyams wrote:

This related, I suppose, and demonstrates that something is going wrong

in wxwidget’s capture stack possibly?

This snippet is from matplotlib:

def _onMiddleButtonUp(self, evt):

“”“End measuring on an axis.”“”

x = evt.GetX()

y = self.figure.bbox.height - evt.GetY()

#print ‘release button’, 1

evt.Skip()

if self.HasCapture(): self.ReleaseMouse()

FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)

Notice the “if HasCapture, Release”. I can very reliably (by right

clicking on a 3D plot to post a popup menu of my own, and then middle

clicking off of it) generate the following exception:

Traceback (most recent call last):

File “C:\Python26\lib\site-packages\matplotlib\backends\backend_wx.py”,

line 1310, in _onMiddleButtonUp

if self.HasCapture(): self.ReleaseMouse()

File “C:\Python26\lib\site-packages\wx-2.9.1-msw\wx_core.py”, line

10494, in ReleaseMouse

return core.Window_ReleaseMouse(*args, **kwargs)

PyAssertionError: C++ assertion “ms_winCaptureCurrent == this” failed at

…..\src\common\wincmn.cpp(2884) in wxWindowBase::ReleaseMouse():

attempt to release mouse, but this window hasn’t captured it

So HasCapture() thinks that the window has the capture, but on releasing

the capture, we find out that we don’t?

Can you reproduce this in a small app that doesn’t need 3rd party libraries?

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


Daniel Hyams

dhyams@gmail.com