1

There are some bug reports on the Internet which say that in Delphi 2009 the TMonitor synchronisation class implementation was severely broken.

However I have also found pages which show fixes (patches) for like here: TMonitor bug? - http://www.thedelphigeek.com/2011/05/tmonitor-bug.html

Are the patches sufficient to fix TMonitor or are there other severe problems?

mjn
  • 36,362
  • 28
  • 176
  • 378
  • 3
    http://stackoverflow.com/questions/4856306/tthreadedqueue-not-capable-of-multiple-consumers There are also various problems in the other SyncObjs classes, from race conditions to cache line contention leading to serialization depending on memory allocation patterns. The situation indicates there was at best very limited testing. You'll be better off using OmniThreadLibrary or other proven libraries, multi-threading is hard enough to begin with, don't burden yourself with fragile primitives. – Eric Grange May 07 '13 at 06:03
  • @EricGrange many thanks for the pointer. So the patch for Delphi 2009 does not fix all known TMonitor problems? – mjn May 07 '13 at 07:39
  • The patch shown for Delphi 2009 fixes only one bug in TMonitor. To patch the second bug, the code after try and before finally must be protected by a `if FWaitQueue <> nil then begin ... end;`. But better test it good before use. The link given by Eric has code to test TMonitor for both bugs. I would still recommend an upgrade. – LU RD May 07 '13 at 08:16
  • Test code was also submitted in the QC reports, [`QC91246 TThreadedQueue fails with multiple consumers`](http://qc.embarcadero.com/wc/qcmain.aspx?d=91246) and [`QC101114 TThreadedQueue fails with multiple consumers part 2`](http://qc.embarcadero.com/wc/qcmain.aspx?d=101114). – LU RD May 07 '13 at 08:42
  • AFAIK the threaded queue problems are only fixed in XE2 update 4, I can't say if there aren't other problems remaining though, or if new problems weren't introduced in XE3/XE4, as I've never bothered with TMonitor again (as I need code that compiles and behaves reliably across versions). – Eric Grange May 07 '13 at 12:54
  • Unresolved problems with TMonitor for example http://stackoverflow.com/questions/14217735/application-hangs-in-sysutils-donemonitorsupport-on-exit, http://qc.embarcadero.com/wc/qcmain.aspx?d=111795, http://qc.embarcadero.com/wc/qcmain.aspx?d=99324 – mjn Jun 26 '13 at 09:32
  • qc99324 is btw hanging during shutdown if sync primitives are not freed. This can be extremely annoying. A small rearrangement and app hangs on shutdown. – Marco van de Voort Dec 29 '13 at 16:39

0 Answers0