TFpTimer thread not cleaned up on application exit if stuck at Synchronize
Original Reporter info from Mantis: cobines
-
Reporter name:
Original Reporter info from Mantis: cobines
- Reporter name:
Description:
TFPThreadedTimerDriver should wait for TFPTimerThread at StopTimer, otherwise the thread may not be finished when it is stuck at Synchronize call when the application is shutting down. Attached timer.pas crashes with the following trace:
An unhandled exception occurred at $08069409 :
EInOutError : Invalid file handle
$08069409 CDONECRITICALSECTION, line 503 of ../unix/cthreads.pp
$0805F444 DONECRITICALSECTION, line 196 of /home/darkman/devel/fpc/rtl/inc/thread.inc
$08080794 COMMONCLEANUP, line 1751 of /home/darkman/devel/fpc/rtl/objpas/classes/classes.inc
$08088CB8 CLASSES_finalize, line 51 of ../unix/classes.pp
$0805C66F FINALIZEUNITS, line 826 of /home/darkman/devel/fpc/rtl/inc/system.inc
$0805C6D8 INTERNALEXIT, line 865 of /home/darkman/devel/fpc/rtl/inc/system.inc
$0805C8B8 DO_EXIT, line 915 of /home/darkman/devel/fpc/rtl/inc/system.inc
$080484F3 main, line 38 of timer.lpr
$B75B5C76
The event that Synchronize() callers wait for is being destroyed while still a thread waits for it. I think adding TThread.WaitFor in StopTimer method will ensure the thread is done before destructor of TFpTimer is done.
Mantis conversion info:
- Mantis ID: 18044
- OS: Debian
- OS Build: Sid
- Build: 16349
- Platform: Linux
- Version: 2.5.1
- Fixed in version: 3.1.1
- Fixed in revision: 16468 (#6954c0a5)
- Target version: 3.0.2