This project has moved and is read-only. For the latest updates, please go here.

Resize cause an "Attempted to read or write protected memory"

Apr 17, 2014 at 6:49 PM
Hi ..

I have a simple test for generate a thumbnail (i went verify the performance versus GDI+). I am using this code:
  public Image ResizeImage(string imageoriginal , int newWidth, int newHeight)
        {
            ImageMagick.MagickImage img =new ImageMagick.MagickImage(imageoriginal);
            //ImageMagick.MagickGeometry geometry = new ImageMagick.MagickGeometry("90x90!");
            img.Resize(90, 90); //<--- error ocurs here.

            return img.ToBitmap();
}
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

imageoriginal contains an image file (tif, jpg, png, bmp)


I get the last version with nuget.
Apr 17, 2014 at 8:19 PM
Does this happen for every image? Or do you have a specific image that fails?
Apr 17, 2014 at 8:30 PM
I tried with different jpg.
I attached two.


2014-04-17 15:19 GMT-04:00 dlemstra <[email removed]>:

From: dlemstra

Does this happen for every image? Or do you have a specific image that fails?

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
William John Adam Trindade
Trois-Rivières - Québec - Canada
Apr 17, 2014 at 8:36 PM
It seems that your reply to an e-mail about a message I posted is automatically posted here. Contact me through Codeplex to send me your example images or use something like dropbox to share them.
Apr 17, 2014 at 9:09 PM
Apr 18, 2014 at 12:04 PM
I cannot reproduce your problem. But this might be related to the recently added OpenCL acceleration. Can you disable OpenCL with the this: 'MagickNET.UseOpenCL = false;' and try it again?

Can you contact me through Codeplex and send me a crashdump (http://msdn.microsoft.com/en-us/library/d5zhxt22.aspx)? Even if this is resolved by disabling OpenCL I would still like to fix the problem.
Apr 18, 2014 at 1:45 PM
Hi,

Now the exception is triggered at
MagickNET.UseOpenCL = false;
Here the log:
System.AccessViolationException occurred
_HResult=-2147467261
_message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
HResult=-2147467261
IsTransient=false
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Magick.NET-x64
StackTrace:
   at Magick.EnableOpenCL(Boolean )
   at ImageMagick.MagickNET.SetUseOpenCL(Boolean value)
InnerException:


The dump (270MB) is disponible in dropbox at:
https://www.dropbox.com/s/uin6v60lrceetz4/ImageViewer2.dmp


Thanks
Apr 18, 2014 at 7:19 PM
Thank you very much for posting that dump but it seems you are using the AnyCPU version of Magick.NET. This is just a wrapper that loads either the x64 or the x86 version of Magick.NET. Could you provide me with a dump from Magick.NET-x64?

And it looks like your dump is from a debugger break point in VisualStudio. Can you run your program outside VisualStudio and create a dump there?
Apr 18, 2014 at 7:37 PM
Same thing with Magick.NET Q16-x64

System.AccessViolationException occurred
_HResult=-2147467261
_message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
HResult=-2147467261
IsTransient=false
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Magick.NET-x64
StackTrace:
   at Magick.EnableOpenCL(Boolean )
   at ImageMagick.MagickNET.SetUseOpenCL(Boolean value)
InnerException:

But now I see this warning:
Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Magick.NET-x64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. WindowsFormsApplication3


Is this the cause?

Thanks
Apr 18, 2014 at 7:58 PM
Edited Apr 19, 2014 at 10:36 PM
You should set the Properties -> Build -> Platform target to x64 to get rid of that warning. And you should still get the same exception.

EDIT:

To provide me with a better dump you should enable Properties -> Debug -> Enable native code debugging in your application.
Apr 19, 2014 at 10:19 PM
Ok.. I forget to force the project use 64bits processor.. but i have the same problem... Here my test case:
https://www.dropbox.com/s/2aisg3lxslty7b6/WindowsFormsApplication3.zip

and here the dump:
https://dl.dropboxusercontent.com/u/25065470/dump.zip

thanks
Apr 19, 2014 at 10:49 PM
I noticed you did not enable 'Enable native code debugging' in the properties of WindowsFormsApplication3. A dump without this does not provide me with enough information. Can you enable this and post a new dump?
Apr 21, 2014 at 5:14 PM
Here the link for dump with Enable native code debugging active:
https://www.dropbox.com/s/t9me1f8vghvbqjo/dump.zip

thanks
Apr 21, 2014 at 5:50 PM
I hope you are not starting to get sick of all my requests but I really want to fix this.

This dump is not reporting an exception? It looks like you are on a breakpoint in Visual Studio.

Feel free to take the discussion of board. You should have my e-mail when I contacted you through CodePlex a couple of days ago.
Apr 21, 2014 at 10:52 PM
Hi..

Thank you for your patience.


Here the link for a dump without breakpoints:
https://dl.dropboxusercontent.com/u/25065470/dump.zip


Thanks
Apr 22, 2014 at 8:08 AM
Thank you very much. This dump contains the information I need to investigate the problem. I will contact you through CodePlex if I need more information.
Apr 22, 2014 at 11:24 AM
I found the problem.

The recent AMD driver (13-12_mobility_win7_win8_64_dd_ccc_whql) has a bug. I installed the old (hp original) and now the code works.

Thank you
Apr 22, 2014 at 11:52 AM
Can you post a link to the bug report? Or is this an unreported bug? I have contacts at AMD that could use your memory dump to fix this. Can you keep the latest dump in your dropbox for a couple of days?
Apr 22, 2014 at 2:56 PM
Edited Apr 22, 2014 at 2:57 PM
It is undocumented.. I call it "bug", but is a incompatibility.

I have a HP Pavilion dv6-3240ca with 2 video cards:
*AMD M880G with ATI Mobility Radeon HD 4250
*AMD Radeon HD 6370M

And the new 13-12_mobility_win7_win8_64_dd_ccc_whql dont suport switch mode (see this: HP DV6 - Updating ATI video drivers )
Can you keep the latest dump in your dropbox for a couple of days?
Yes.. i can.
Apr 24, 2014 at 8:07 PM
Can you please reply to the e-mail I send you through Codeplex? We need a bit more information.