System.AggregateException using TPL
developervariety opened this issue · 1 comments
developervariety commented
System.AggregateException: One or more errors occurred. (One or more errors occurred. (Specified argument was out of the range of valid values.)) ---> System.AggregateException: One or more errors occurred. (Specified argument was out of the range of valid values.) ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at at System.Span`1.Slice(Int32 start, Int32 length)
at at SixLabors.Memory.ArrayPoolMemoryAllocator.Buffer`1.GetSpan()
at at System.Memory`1.get_Span()
at at SixLabors.ImageSharp.Memory.Buffer2D`1.get_Span()
at at SixLabors.ImageSharp.Memory.Buffer2D`1.get_Item(Int32 x, Int32 y)
at at SixLabors.ImageSharp.Image`1.get_Item(Int32 x, Int32 y)
at at CoenM.ImageHash.HashAlgorithms.PerceptualHash.Hash(Image`1 image)
at rcs.Core.Processor.<>c__DisplayClass3_2.<GuessAngle>b__1(Int32 i) in D:\GitHub\rcs\rcs\Core\Processor.cs:75
at at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
at at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
at rcs.Core.Processor.GuessAngle(String path, Int32 count) in D:\GitHub\rcs\rcs\Core\Processor.cs:72
at rcs.Program.<>c.<<Main>b__1_1>d.MoveNext() in D:\GitHub\rcs\rcs\Program.cs:78
--- End of inner exception stack trace ---
at at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at at System.Threading.Tasks.Task.Wait()
at rcs.Program.<>c.<<Main>b__1_0>d.MoveNext() in D:\GitHub\rcs\rcs\Program.cs:121
at at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__7_1(Object state)
at at System.Threading.QueueUserWorkItemCallbackDefaultContext.<>c.<.cctor>b__5_0(Object state)
at at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at at System.Threading.QueueUserWorkItemCallbackDefaultContext.ExecuteWorkItem()
at at System.Threading.ThreadPoolWorkQueue.Dispatch()
at at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at at System.Span`1.Slice(Int32 start, Int32 length)
at at SixLabors.Memory.ArrayPoolMemoryAllocator.Buffer`1.GetSpan()
at at System.Memory`1.get_Span()
at at SixLabors.ImageSharp.Memory.Buffer2D`1.get_Span()
at at SixLabors.ImageSharp.Memory.Buffer2D`1.get_Item(Int32 x, Int32 y)
at at SixLabors.ImageSharp.Image`1.get_Item(Int32 x, Int32 y)
at at CoenM.ImageHash.HashAlgorithms.PerceptualHash.Hash(Image`1 image)
at rcs.Core.Processor.<>c__DisplayClass3_1.<GuessAngle>b__1(Int32 i) in D:\GitHub\rcs\rcs\Core\Processor.cs:93
at at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at at System.Threading.Tasks.TaskReplicator.Replica.Execute()
developervariety commented
Fixed it, nothing wrong with the library..
foreach (string t in images)
{
if (!IsValidGdiPlusImage(t)) continue;
using Image<Rgba32> image = Image.Load(t);
ulong imgHash1 = hashAlgorithm.Hash(image);
Parallel.For(0, Globals.Signatures.Count, i =>
{
ulong imgHash2 = Convert.ToUInt64(Globals.Signatures[i]);
double weight = CompareHash.Similarity(imgHash1, imgHash2);
if (!(weight >= score)) return;
score = weight;
frame = t;
hash = imgHash2;
});
}