Skip to content

Possible error or defect #50

@sezuk

Description

@sezuk

In the function FastMM_GetMem_GetLargeBlock

    {Insert the block in the first available arena.}
    while True do
    begin

      LPLargeBlockManager := @LargeBlockManagers[0];
      for LArenaIndex := 0 to CFastMM_LargeBlockArenaCount - 1 do
      begin

        if (LPLargeBlockManager.LargeBlockManagerLocked = 0)
          and (AtomicExchange(LPLargeBlockManager.LargeBlockManagerLocked, 1) = 0) then
        begin
          PLargeBlockHeader(Result).LargeBlockManager := LPLargeBlockManager;

          {Insert the large block into the linked list of large blocks}
          LOldFirstLargeBlock := LPLargeBlockManager.FirstLargeBlockHeader;
          PLargeBlockHeader(Result).PreviousLargeBlockHeader := Pointer(LPLargeBlockManager);
          LPLargeBlockManager.FirstLargeBlockHeader := Result;
          PLargeBlockHeader(Result).NextLargeBlockHeader := LOldFirstLargeBlock;
          LOldFirstLargeBlock.PreviousLargeBlockHeader := Result;

          LPLargeBlockManager.LargeBlockManagerLocked := 0;

          {Add the size of the header}
          Inc(PByte(Result), CLargeBlockHeaderSize);

          Exit;
        end;

        {Try the next arena.}
        Inc(LPLargeBlockManager);
      end;

    end;

    {All large block managers are locked:  Back off and try again.}
    LogLargeBlockThreadContentionAndYieldToOtherThread;

The call to LogLargeBlockThreadContentionAndYieldToOtherThread must be inside a loop, otherwise it will never reach it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions