Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get System.AccessViolationException when concurrently read two or more large image files in x86 mode #1231

Closed
linhnddev opened this issue Aug 18, 2022 · 4 comments
Milestone

Comments

@linhnddev
Copy link

linhnddev commented Aug 18, 2022

Magick.NET version

Magick.NET-Q16-AnyCPU 12.0.1

Environment (Operating system, version and so on)

WinUI3, Windows 11 - 21H2, 32GB RAM

Description

When I tried to read two or more large image files (heic photos from iPhone), I got the System.AccessViolationException and the app crashed.
It only happens when debugging in x86 mode. I tried in x64 mode got no problem.

If file size is about 2-3MB, 4-5 concurrent tasks will causes the exception.
If file size is about 9-10MB, it happens with 2 concurrent tasks.

Don't know if it relates to the memory. The app memory shows in Task Manager is about 100-200MB

Steps to Reproduce

  • Set debug mode to x86
  • Load two or more 9-10MB heic files concurrently.
  • Wait for some seconds, AccessViolationException will occur
@dlemstra
Copy link
Owner

I suspect that you are running out of memory. 32-bit processes have a hard limit and that might result in a memory allocation not working that is not properly handled.

If you can provide me with a small example and test images that I can use to reproduce this I can give you a better answer.

@linhnddev
Copy link
Author

Hi,

I have made a test project:
https://1drv.ms/u/s!AgNCgKvaRLYoifZ033-0ruF3rfAw0Q?e=HPaLSE

Hope you can reproduce the bug.

@dlemstra
Copy link
Owner

Thanks for the sample and I was able to reproduce your issue. But it turns out that this is an issue in another library than ImageMagick. I opened a pull request for this but I also applied the patches to our local copy so this will be resolved in the next release of Magick.NET. But you will then get an exception that the image cannot be created due to memory allocation failure.

@dlemstra dlemstra added this to the 12.1.0 milestone Aug 18, 2022
@linhnddev
Copy link
Author

Thank you 🙏!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants