Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

.NET Core: undefined symbol: GOMP_parallel while loading RAW image

Open madrian-es opened this issue 7 years ago • 7 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am using the latest version of Magick.NET
  • [x] I have searched open and closed issues to ensure it has not already been reported

Description

We're building a .NET Core app that converts images to Pyramid TIFFs. Most images work, but the RAW test files we have don't. The app crashes with the following error:

./magick_test: symbol lookup error: /opt/magick_test/Magick.NET-Q8-x64.Native.dll.so: undefined symbol: GOMP_parallel

After a lot of trial and error, we found that calling new MagickImage([string]) caused the above error, while new MagickImage([FileStream]) works all the time.

Steps to Reproduce

Run the following code with this test image.

The error will show up in linux, but not windows.

static void Main(string[] args)
{
    string inputPath = @"/path/to/raw.cr2";
    string outputPath = @"/path/to/ptif.tif";
    //FileStream fileStream = new FileStream(pathToFile, FileMode.Open);
    using (MagickImage magickImage = new MagickImage(inputPath))
    {
        magickImage.Format = MagickFormat.Ptif;
        magickImage.Settings.SetDefine(MagickFormat.Tiff,
            "ignore-layers",
            true);
        magickImage.Settings.SetDefine(MagickFormat.Tiff,
            "tile-geometry",
            "256x256");
        magickImage.Settings.Compression = CompressionMethod.JPEG;
        magickImage.Settings.ColorSpace = ColorSpace.RGB;
        magickImage.Write(outputPath);
    }
}

System Configuration

  • Magick.NET version: 7.10.2 (NuGet)
  • Environment (Operating system, version and so on): Ubuntu 16.04.5 LTS, .NET Core 2.2

madrian-es avatar Feb 05 '19 09:02 madrian-es

Is it possible to create a docker image that I can use to reproduce this issue?

dlemstra avatar Feb 05 '19 16:02 dlemstra

I don't know how useful will this be but:

Uses new MagickImage([string]):

docker run adrianlibnova/tests:latest /opt/magick_test_error/magick_test /opt/TEST.CR2 /opt/out.ptif

Uses new MagickImage([FileStream]):

docker run adrianlibnova/tests:latest /opt/magick_test_error/magick_test /opt/TEST.CR2 /opt/out.ptif

The test file is inside the docker image. The source code is exactly as my issue, but i'm using args[] instead of fixed paths.

madrian-es avatar Feb 07 '19 15:02 madrian-es

I was actually looking for a DockerFile so I can see what is happening and inspect the host easier.

dlemstra avatar Feb 07 '19 16:02 dlemstra

Clone this repo and build.

Let me know if you need anything else.

madrian-es avatar Feb 07 '19 16:02 madrian-es

Thanks for helping me out and providing the test repo. It turns out that libraw (that is used for CR2 libraries) was build with OpenMP enabled. Just pushed a patch to fix this.

dlemstra avatar Feb 07 '19 19:02 dlemstra

What I don't understand is why did it work with a FileStream and not the path? Is it not processing the raw using the FS method? Could it be processing an embedded thumbnail instead?

madrian-es avatar Feb 08 '19 08:02 madrian-es

It probably has to do with the code path that will be used. When you use the FileStream it will create a temporary file and pass that to the libraw library. But that file will not have the CR2 extension. I am guessing that a different code path was chosen based on the extension. Could take a deeper look at this but OpenMP should definitely be disabled in the libraw library.

dlemstra avatar Feb 08 '19 08:02 dlemstra