JOGL+Mesa+Matlab on linux

I am developing app in Matlab using JOGL. When software opengl rendering selected (software MESA without dri module) then simply closing window with GLCanvas inside (for example demo Gears) causes deadlock. Maybe it is not problem of JOGL. As I could debug, the deadlock is caused by calling GLXDestroyContext() in removeNotify(). More precisely, calling XSync() in Mesa code deadlocks Matlab.

Outside Matlab everything works fine.

Deadlock can be “workarounded” by adding one second pause to removeNotify() method. But it is not solution for me.

Can anyone help?
Thank you,
Pavel