Calling keyboard's capture() from within a keyboard event handler makes Jack a very sad boy on Mac. This can easily happen with Ogre3d, where it appears typical to put keyboard capture() within frameStarted(). Triggering is as easy as calling Ogre's renderOneFrame(). On Windows, this bug didn't crash (and I didn't check out the code to see why).
Apparently the mess happens when OIS tries to dereference an iterator in the "parent" call to capture() once that resumes. However this iterator was already cleared from the pendingEvents map/vector/whatever in the "child" call to capture() -- in the one caused by, e.g., renderOneFrame().
Perhaps a check variable should be added, some sort of a lock mechanism: if we're already within capture() function, then let's do a 'return' immediately at the top?
practical sample:
* user presses enter on "Load" menu
* parsing keypress events starts in capture()
* function for loading next level is called. renderOneFrame() is used to display the loading screen, but nothing else
* renderOneFrame() calls frameStarted() which calls capture(); after parsing events, clear() is called
* loading proceeds
* loading finishes, parsing keypress events in capture() attempts to resume, but crashes since clear was called and dereferencing, incrementing, etc. of the iterator must fail
(This bug was encountered with PythonOgre, but I see no reason for it to be specific to the language and the wrapper; it seems like perfectly easy to trigger by coding in C++.)