Hang in System.SysFreeMem [Edit]

Giganews Newsgroups
Subject: Hang in System.SysFreeMem [Edit]
Posted by:  Ales Gregor
Date: Wed, 29 Aug 2012

Hello,

We have massively multithread COM+ application, 100’s of threads, written in Delphi 2009. One of our clients it reporting  application hang which they claim occurs every business day when the application runs on dual-core virtual image, it never occurs when it runs on single-core virtual image.

Using DebugDiag  we figured out that number of threads is in infinitive loop in System. SysFreeMem, because of critical sections deeper in the call stack almost all threads are waiting.
It seems it is following code in function SysFreeMem in getmem.inc. We assume BlockTypeLocked is non zero, and therefore cannot be locked and there’re the loop never ends.

    {Lock the block type}
    if IsMultiThread then
    begin
      while (LockCmpxchg(0, 1, @LPSmallBlockType.BlockTypeLocked) <> 0) do
      begin
        if not NeverSleepOnMMThreadContention then
        begin
          Sleep(InitialSleepTime);
          if LockCmpxchg(0, 1, @LPSmallBlockType.BlockTypeLocked) = 0 then
            Break;
          Sleep(AdditionalSleepTime);
        end;
      end;
    end;

Did anybody ever come across issue like this?
What could possibly cause that LPSmallBlockType.BlockTypeLocked is infinitively locked?
Is there anything I can do to avoid  this hang?
Can you see any relation between the hang and the dual-core virtual image?

Thanks for any idea
Ales

Edited by: Ales Gregor on Aug 29, 2012 5:17 AM

Replies