gabr42 / gabr42/OmniThreadLibrary
Shutdown av in DsiTimeGetTime64
- Dominant language
- Pascal
- Stars
- 513
- Forks
- 147
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I'm getting this av on application shutdown -
Exception class $C0000005 with message 'access violation at 0x76fca996: write of address 0x00000014'. Process FinalBuilder9.exe (21408)
````
76fb4213 ntdll.RtlEnterCriticalSection + 0x63
:00d2110c DSiTimeGetTime64 + $10
:00d55ff6 TOTPWorker.MainteinanceTimer + $9E
````
As far as I can tell, this is an issue with `CleanupGlobals` deleting the criticalsection that `DSiTimeGetTime64` references - it looks like the TOTPWorker.MainteinanceTimer is still running when CleanupGlobals is called.
I asked claude and it suggested this change
````delphi
procedure CleanupGlobals;
begin
timeEndPeriod(1);
DSiCloseHandleAndNull(GTerminateBackgroundTasks);
// Intentionally NOT deleting these process-global critical sections: OTL's thread-pool
// maintenance thread (TOTPWorker.MainteinanceTimer -> DSiTimeGetTime64) can still be running
// at shutdown and would AV in RtlEnterCriticalSection on a deleted section. Leaking them is
// safe - Windows reclaims them at process exit.
// DeleteCriticalSection(GDSiWndHandlerCritSect);
// DeleteCriticalSection(GDSiTimeGetTime64Safe);
DSiUnloadLibrary;
FreeAndNil(_GLibraryList);
end;
````
I haven't tried the change yet but I thought it was worth reporting
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing CleanupGlobals alongside DSiTimeGetTime64 and TOTPWorker.MainteinanceTimer, focusing on shutdown ordering and the critical sections mentioned in the report. Reproduce application shutdown if possible, then validate whether the proposed cleanup change prevents the access violation without leaving the maintenance thread active.
Written by the indexing model from the issue text.
Assessment
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100