Skip to content

Possible bug in TOmniValueQueue #201

@TommiPrami

Description

@TommiPrami

No idea if I can make reproducible case out of this, most likely not, but I have situation when I put stuff in the Queue, canel the multithreaded process.

TOmniValueQueue.Destroy gets called, on FreeAndNil(FInnerQueue);

calls to the TOmniValueQueue.CollectionNotifyEvent starts firing, and the FInnerQueue is freed in this point.

made following change to the procedure

procedure TOmniValueQueue.CollectionNotifyEvent(Sender: TObject;
  const Item: TOmniValue; Action: TCollectionNotification);
var
  AfterCount: integer;
begin
  // This method occurs within the critical section.
  AfterCount := -1; // <- Change starts 
  if Assigned(FInnerQueue) then
    AfterCount := FInnerQueue.Count; // <- Change ends

Maybe this should be handled earlier, or ion completely other way, in TOmniValueQueue or in my code. but it seems that this will get rid of Access Violation, or the destructor TOmniValueQueue.Destroy; should firs clear the Queue, before releasing FInnerQueue

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