I am trying to track access violation. Reproducibility seems non-deterministic and rare, so I want to test some of my assumptions before moving on.
Access violation occurs in FastMM4 version 4.991 in the DebugGetMem function in the following code:
if (ASize > (MaximumMediumBlockSize - BlockHeaderSize - FullDebugBlockOverhead)) or CheckFreeBlockUnmodified(Result, GetAvailableSpaceInBlock(Result) + BlockHeaderSize, boGetMem) then begin {Set the allocation call stack} GetStackTrace(@PFullDebugBlockHeader(Result).AllocationStackTrace, StackTraceDepth, 1); {Set the thread ID of the thread that allocated the block} PFullDebugBlockHeader(Result).AllocatedByThread := GetThreadID; // ** AV Here {Block is now in use: It was allocated by this routine} PFullDebugBlockHeader(Result).AllocatedByRoutine := @DebugGetMem;
The exception is:
Project Workstation.exe raised the exception class $ C0000005 with the message "Access violation at address 0x01629099: reading address 0x66aed8f8".
The call stack is usually the same. It is called from a drawing event in a virtual tree view in which I call Format('%s %s %s', [vid, node, GetName()]) , although I doubt that this is really relevant (except that Format allocates dynamic memory).
I am using FullDebugMode (obviously) and CheckHeapForCorruption .
I also installed the following:
- Enabling
CatchUseOfFreedInterfaces does not show anything new. I still get the same access violation, and no further diagnostics. - I once reproduced an
FullDebugModeScanMemoryPoolBeforeEveryOperation := True using FullDebugModeScanMemoryPoolBeforeEveryOperation := True , although I canโt remember if CatchUseOfFreedInterfaces turned on or off in this case. - This is not a concurrency issue; my application is single threaded. (Actually, this is not entirely true. I am using Virtual TreeView, which creates a hidden workflow, but if this is really the reason, then the error is in Virtual TreeView and not in my code, which is rather unlikely.)
Do I believe that, despite the fact that CheckHeapForCorruption does not intercept anything, this exception can only be related to the fact that my code damaged a bunch? Is there anything else that could cause FastMM4 to crash this way?
Any suggestions for further diagnosis, or even make the failure more reproducible?
source share