[Lazarus] Lazarus application crash. Is PostMessage thread safe?

Giuliano Colla giuliano.colla at fastwebnet.it
Tue Feb 16 12:25:42 CET 2016


Il 16/02/2016 10:04, Michael Schnell ha scritto:
> a (potential) bug (in "Glib2" whatever this exactly means)

Glib2 means version 2 of GTK Glib, which is used by Qt (and by GTK) to 
implement the main event loop.
libglib-2.0.so.0

The full picture (from stack trace) is as follows:

 1. The main loop of Lazarus (under Qt WS) calls AppWaitMessage in
    qtobject.inc
 2. qtobject calls QCoreApplication::processEvents in qcoreapplication_c.cpp
 3. qcoreapplication_c.cpp calls QEventDispatcherGlib in libQtGui.so.4
 4. QEventDispatcherGlib calls g_main_context_iteration in
    libglib-2.0.s0.0 (the Glib2)
 5. if g_main_context_iteration has pending messages, it calls
    g_main_context_dispatch
 6. g_main_context_dispatch calls QCoreApplicationPrivate::sendPostedEvents

When the user code calls Application.ProcessMessages the same sequence 
occurs:
AppProcessMessages in QtObjects.inc is called, which then calls 
QCoreApplication::processEvents, and all the steps from 2 on are identical.

My feeling is that the bug is sort of this: if the call to 
Application.ProcessMessages causes a recursion, and a new different 
message has arrived in the meantime, g_main_context_iteration() 
understands rightly that there is a pending message to dispatch, but it 
decides wrongly to dispatch again the old one, instead of the new one.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160216/13de7f83/attachment-0003.html>


More information about the Lazarus mailing list