Why copying some value to a pointer results in access violation exception only in Release mode in assembly application?

1

i have a WPF .Net Core application, which uses assembly library to transform an image. Some memory is allocated in C# code like this:

var destinationImageArray = new byte[destinationImageWidth, destinationImageHeight, 4];

Then the pointer for a table is created and passed to the assembly procedure as an argument:

fixed (byte* destinationImagePointer = &destinationImage[0, 0, 0])
{
    TransformIntoShrinkedBitmap(sourceImagePointer,
         destinationImagePointer,
         (float) xRatio,
         (float) yRatio,
         startColumnIndex,
         columnCount,
         destinationImageHeight,
         sourceImageHeight);
}

The assembly code has to fill the mentioned table with some generated values. The whole problem, is that my solution works correctly, only when i compile it in Debug mode. When i compile it in Release, i get the following error, while trying to copy the first value to the cell pointed by the table pointer: "Exception thrown at 0x00007FFA4EA6107B (...dll) in ...: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.". The exception occurs when the this line is executed:

MOV [R15], AL ; Copy pixel compositional A to destination image

I have no idea why the code is working properly in Debug mode, and does not work in Release. Does anybody have any idea? Thanks for any help

c#
wpf
assembly
asked on Stack Overflow Nov 7, 2020 by Bulchsu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0