It is hard to diagnose your problem without seeing the actual error message. Is it an actual EAccessViolation
exception, or is it a different type of exception? Just because an exception is raised does not guarantee it is actually an EAccessViolation
unless it really is an Access Violation.
TIdStack.IncUsage()
ensures that Indy's global GStack
object exists. That object is what provides access to all of the low-level platform-specific socket API functions used throughout Idny. IncUsage()
itself is a class
method, so it is not called on a TIdStack
object instance, so merely calling IncUsage()
itself is not the cause of the exception.
Internally, IncUsage()
uses three global variables in the IdStack
unit:
GStackCriticalSection: TIdCriticalSection
GInstanceCount: LongWord
GStackClass: TIdStackClass
All three variables are initialized to 0
/nil
in their respective declarations, and then GStackClass
and GStackCriticalSection
are assigned/constructed in the initialization
section of the IdStack
unit.
An exception can only occur if one of those variables is invalid at the time IncUsage()
is called (unless the exception is coming from a TIdStack
constructor, but I do not see that in your call stack).
Perhaps something in your project is preventing the initialization
from being called, causing IncUsage()
to crash when it tries to enter the GStackCriticalSection
lock (but I do not see TIdCriticalSection.Enter
in your call stack)? There is an Assert()
to make sure GStackCriticalSection
is not nil
before it is used, but maybe your copy of Indy was compiled with asserts disabled?