Open Rura1980 opened 5 years ago
Provide a minimal working example (http://sscce.org), please.
I am using Delphi XE. Modified code a little bit and now my program crashes (but not always) with access violation in OtlSync line 1891 FAwaitedLock.Acquire.
It seems to be something quite simple, but I cannot figure it out... Any comments are welcomed.
program DeCalTest;
{$APPTYPE CONSOLE}
uses FastMM4, Windows, SysUtils, Classes, SyncObjs, Generics.Collections, OtlParallel, OtlCommon, OtlCollections, OtlTask, OtlTaskControl;
procedure ProcessMessages; var Msg: TMsg; begin while PeekMessage( Msg, 0, 0, 0, PM_REMOVE ) do begin TranslateMessage( Msg ); DispatchMessage( Msg ); end; end;
procedure TestFutures;
var
x: array of IOmniFuture
begin ReportMemoryLeaksOnShutdown := DebugHook <> 0; Randomize;
TestFutures; Writeln( 'Press any key' ); ProcessMessages; Readln;
end.
This program crashed but not always with access violation in OtlSync line 1891 FAwaitedLock.Acquire.
Sorry, but I can't repeat your problem with Delphi 10.3 Rio and latest OmniThreadLibrary source code.
I cannot repeat my problem with Delphi 10.3 Rio either. Very strange.
I call Parallel.Future in a for loop and store IOmniFuture in a array of IOmniFuture. Later I want to iterate through this array and call future.Value for each element. Unfortunately, this code fails occasionly with TList.IndexOutOfBounds. When I wait for the future to complete before adding to dynamic array, everything works fine. What am I doing wrong?