Skip to content

Crash when writing PNG in Parallel.ForEach on Magick.NET-Q8-x64 14.10.2 #1956

@junji19750412-lab

Description

@junji19750412-lab

Magick.NET version

14.10.2

Environment (Operating system, version and so on)

Windows 11 x64

Description

Summary

After upgrading to Magick.NET-Q8-x64 14.10.2, the process crashes when saving PNG images in parallel.
This did not occur in 14.10.1. JPEG are not affected.

The crash happens even when only loading and saving a PNG (no resize, no colorspace change).


Environment

  • OS: Windows 11 x64
  • .NET Runtime: .NET 10.0.2
  • Magick.NET: Magick.NET-Q8-x64 14.10.2
  • CPU: x64
  • Execution model: Parallel.ForEach

Behavior

  • Saving PNG images in Parallel.ForEach causes a process crash

  • Exception observed:

    • ExecutionEngineException
    • Native crash during PNG write
  • try/catch cannot catch the error (process terminates)

  • The same code works correctly when executed sequentially

  • The same code works correctly with Magick.NET-Q8-x64 14.10.1


Not affected

  • JPEG save (parallel): OK
  • PNG save (sequential): OK
  • PNG load only (parallel): OK

Steps to Reproduce

Reproduction steps

  1. Prepare multiple PNG files

  2. Run a Parallel.ForEach loop

  3. Inside the loop:

    • Create a MagickImage from a PNG file
    • Immediately call Write() to save as PNG
  4. Set MaxDegreeOfParallelism to 2 or higher

  5. The process crashes during execution

Even a simple read + write of PNG files causes the crash.


Additional notes

  • ResourceLimits.Thread = 1 does not prevent the crash
  • Q16-x64 was also tested and showed similar instability
  • Setting ColorSpace or resizing is not required to reproduce
  • The issue appears to be specific to the PNG encoder in 14.10.2

Regression

✔ Works in 14.10.1
❌ Crashes in 14.10.2

This appears to be a regression related to PNG writing in multithreaded scenarios.


Expected behavior

PNG images should be writable safely in parallel, or at least fail gracefully without crashing the process.

Thank you for your work on Magick.NET.

Images

Images: Not applicable (process crashes before output can be generated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions