Skip to content

Conversation

@brianpopow
Copy link
Collaborator

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This is a fix for #1416. Calculation of the histogram was done in parallel without locking.

@brianpopow brianpopow added the bug label Nov 8, 2020
@codecov
Copy link

codecov bot commented Nov 8, 2020

Codecov Report

Merging #1418 (5c8f66c) into master (b37044f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1418   +/-   ##
=======================================
  Coverage   83.08%   83.08%           
=======================================
  Files         707      707           
  Lines       31839    31839           
  Branches     3590     3590           
=======================================
+ Hits        26454    26455    +1     
+ Misses       4668     4667    -1     
  Partials      717      717           
Flag Coverage Δ
unittests 83.08% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...on/GlobalHistogramEqualizationProcessor{TPixel}.cs 96.42% <100.00%> (ø)
src/ImageSharp/Memory/MemoryOwnerExtensions.cs 100.00% <0.00%> (+14.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b37044f...ae27c04. Read the comment docs.

int luminance = ImageMaths.GetBT709Luminance(ref vector, levels);
Unsafe.Add(ref histogramBase, luminance)++;
ref int histogramAtLuminance = ref MemoryMarshal.GetReference(this.histogramBuffer.Slice(luminance));
Interlocked.Increment(ref histogramAtLuminance);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this have been

Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes right, dont know why i did it so over complicated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why net472 tests are failing now. Its not the histogram tests:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at ImageMagick.PixelCollection.NativeMethods.X86.PixelCollection_ToByteArray(IntPtr Instance, UIntPtr x, UIntPtr y, UIntPtr width, UIntPtr height, IntPtr mapping, IntPtr& exception) at ImageMagick.PixelCollection.NativePixelCollection.ToByteArray(Int32 x, Int32 y, Int32 width, Int32 height, String mapping) ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an intermittent issue with ImageMagick. Maybe caused by OOM but I'm not sure. I just reset when I see it.

@JimBobSquarePants JimBobSquarePants merged commit abc1573 into master Nov 8, 2020
@JimBobSquarePants JimBobSquarePants deleted the bp/Issue1416 branch November 8, 2020 18:23
JimBobSquarePants added a commit that referenced this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants