Thread: [Pyobjc-dev] bus error in CGEventTapCreate... found the problem
Brought to you by:
ronaldoussoren
From: Ratko J. <rja...@gm...> - 2009-06-29 22:39:43
|
I am trying to capture some mouse events using CGEventTapCreate and I found out that the following causes a bus error every time: eventMask = (1<<kCGEventMouseMoved) eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback) I've traced it down to two problems, both in Quartz framework in _callbacks.m in the function m_CGEventTapCreate: (1) the function expects 5 inputs and yet it tries to assign 6, last one being "info"... which ends up being an uninitialized pointer. That seems to cause a bus error further down when it tries to create a tuple of "callback" and "info": PyObject* real_info = Py_BuildValue("OO", callback, info); For my purposes, I just changed CGEventTapCreate to accept 6th input when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if that's the right approach... (2) After fixing that, I encountered the next bus error with the line further down in the same function: CFRelease(retval); I have no idea why this is crashing but I just commented it out for now. I am assuming the worst that can happen is a memory leak and considering that I call this only once, I didn't think it was a big problem. Also, how does one compile svn trunk properly??? "easy_install pyobjc" downloads a new version when I want it to compile my modified version. Right now I have a serious hack... the whole 2.2b2 from easy_install + Quartz compiled separately from svn (2.2b3). Some system info:Mac OS X 10.5.7 Apple Python 2.5 built-in PyObjC (also tried PyObjC 2.2b2) -Ratko |
From: Ronald O. <ron...@ma...> - 2009-06-30 09:54:58
|
On 30 Jun, 2009, at 0:38, Ratko Jagodic wrote: > I am trying to capture some mouse events using CGEventTapCreate and > I found out that the following causes a bus error every time: > > eventMask = (1<<kCGEventMouseMoved) > eventTap = CGEventTapCreate(kCGSessionEventTap, > kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback) > > > I've traced it down to two problems, both in Quartz framework in > _callbacks.m in the function m_CGEventTapCreate: > > (1) the function expects 5 inputs and yet it tries to assign 6, last > one being "info"... which ends up being an uninitialized pointer. > That seems to cause a bus error further down when it tries to create > a tuple of "callback" and "info": > PyObject* real_info = Py_BuildValue("OO", > callback, info); > For my purposes, I just changed CGEventTapCreate to accept 6th input > when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if > that's the right approach... > > > (2) After fixing that, I encountered the next bus error with the > line further down in the same function: > CFRelease(retval); > I have no idea why this is crashing but I just commented it out for > now. I am assuming the worst that can happen is a memory leak and > considering that I call this only once, I didn't think it was a big > problem. Thanks for the bugreport. > > > > Also, how does one compile svn trunk properly??? "easy_install > pyobjc" downloads a new version when I want it to compile my > modified version. Right now I have a serious hack... the whole 2.2b2 > from easy_install + Quartz compiled separately from svn (2.2b3). This should work just fine. Building the entire trunk is not very convenient at the moment, there is a script for rebuilding everything at the toplevel in the repository (that is, the directory that also contains pyobjc-core). This script runs 'python setup.py develop' on all subprojects. Ronald > > > Some system info: > Mac OS X 10.5.7 > Apple Python 2.5 > built-in PyObjC (also tried PyObjC 2.2b2) > > > -Ratko > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ronald O. <ron...@ma...> - 2009-07-14 07:15:30
|
It has taken me way to long to get around to this, but I finally commited a fix for this (revision 2266 and 2267). I still have to write a unittest that uses this API, but that can wait. On 30 Jun, 2009, at 0:38, Ratko Jagodic wrote: > I am trying to capture some mouse events using CGEventTapCreate and > I found out that the following causes a bus error every time: > > eventMask = (1<<kCGEventMouseMoved) > eventTap = CGEventTapCreate(kCGSessionEventTap, > kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback) > > > I've traced it down to two problems, both in Quartz framework in > _callbacks.m in the function m_CGEventTapCreate: > > (1) the function expects 5 inputs and yet it tries to assign 6, last > one being "info"... which ends up being an uninitialized pointer. > That seems to cause a bus error further down when it tries to create > a tuple of "callback" and "info": > PyObject* real_info = Py_BuildValue("OO", > callback, info); > For my purposes, I just changed CGEventTapCreate to accept 6th input > when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if > that's the right approach... Adding an extra "O" was the correct fix here. > > > (2) After fixing that, I encountered the next bus error with the > line further down in the same function: > CFRelease(retval); > I have no idea why this is crashing but I just commented it out for > now. I am assuming the worst that can happen is a memory leak and > considering that I call this only once, I didn't think it was a big > problem. This should have been "if (result) { CFRelease(result); }". Ronald |