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

Giuliano Colla giuliano.colla at fastwebnet.it
Thu Feb 11 01:09:19 CET 2016


Il 10/02/2016 22:12, C Western ha scritto:
> My understanding is Application.ProcessMessages has to be reentrant 
> for the clipboard to work, at least under X, as clipboard content is 
> retrieved by receiving messages. See 
> http://bugs.freepascal.org/view.php?id=26242 for a (fixed) bug that 
> showed this up. The sequence is something along the lines of (for 
> example) ProcessMessages -> Handle paste button -> clipboard -> 
> ProcessMessages.

Well, in general it appears to behave, otherwise a lot of code would fail.
I just stumbled in a special case, when Application.ProcessMessages is 
called from within the handler of a message posted by a PostMessage from 
a different thread. It would appear that, under some circumstances 
(because the error appears randomly), there's a bug which causes it to 
pass again the same message, thus causing and endless loop. It's the 
recursion in this specific case which appears to be buggy.

Giuliano





More information about the Lazarus mailing list