On 9/15/2016 12:45 PM, Anton Tarasov wrote:
Please review the fix:
(The bug is currently closed as “not an issue”, which is not quite
true. So once and if the fix is approved I can take the ownership of
The problem is this. Sometimes when a frame is closed there may appear
a race condition:
- removeNotify() is called on the frame on EDT and it removes all the
events associated with the frame from the event queue.
- The frame is requested by accessibility via the CAccessibility
static methods (like CAccessibility.getAccessibleIndexInParent). Those
methods are called from native on AppKit thread and they perform via
invokeAndWait. The latter is wrapped with an InvocationEvent whose
source is set to the frame. But, once the event is put on the event
queue, it's purged by the removeNotify() call. As the result,
invokeAndWait returns null. Then, in some of the mentioned methods
'null' is unboxed to a primitive 'int' or 'boolean' which results in
NPE propagated to native. On the native side, the NPE is not properly
handled and is just re-thrown.
I forgot to add, as a comment to the fix, that createWithAccessible() is
ok to return nil, it's checked.
I don't have a simple and safe solution for the race. So, I suggest to
fix the NPE/crash at least.