ArtifexSoftware / Ghostscript.NET

Ghostscript.NET - managed wrapper around the Ghostscript library (32-bit & 64-bit)
https://ghostscript.com
GNU Affero General Public License v3.0
391 stars 152 forks source link

Random App Pool crashes #98

Open WilliamDoman opened 2 years ago

WilliamDoman commented 2 years ago

I've been using version 1.2.1 for 3 or 4 years. Without issue. Thank you!!!

It would fail once in a while but WAS would restart the app pool and it was fine. Randomly this week it started crashing the app pool every 5/10/15 minutes.

After reading issue #34 I upgraded to 1.2.3 and upgraded gsdll64.dll to the latest 9.55 and have had no improvement. I've also tried to load dll from memory set to false and that fails to run.

It is crashing across 2 IIS servers. I does seem that it may have some sort of environmental cause, but it works on dozens of pdf's before it crashes the app pool. It doesn't seem to be any sort of memory leak.

Any ideas?

 GhostscriptVersionInfo version = new GhostscriptVersionInfo(
                                                                    new Version(0, 0, 0), PathToGhostScriptDLL,
                                                                    string.Empty, GhostscriptLicense.GPL);

 using (rasterizer = new GhostscriptRasterizer())
            {
                rasterizer.Open(pdfContent, version, true);
               ....
                 Image img = rasterizer.GetPage(DIP, page);

The stack traces from the IIS debugger

[[HelperMethodFrame]] System.Drawing.Bitmap..ctor(Int32, Int32, System.Drawing.Imaging.PixelFormat)+a2 Ghostscript.NET.Viewer.GhostscriptViewerImage..ctor(Int32, Int32, Int32, System.Drawing.Imaging.PixelFormat)+59 Ghostscript.NET.Viewer.GhostscriptViewerDisplayHandler.Presize(IntPtr, IntPtr, Int32, Int32, Int32, UInt32)+73 DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int32, Int32, Int32, Int32)+64 DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, System.String, Int32, Int32 ByRef)+154 [[InlinedCallFrame]] Ghostscript.NET.Interpreter.GhostscriptInterpreter.Run(System.String)+8a Ghostscript.NET.Viewer.GhostscriptViewer.ShowPage(Int32, Boolean)+529 PDF2ImageFactory.CreatePageImagesFromPDF(System.String, System.IO.MemoryStream, Int32, System.Collections.Generic.List`1)+5a6

And the error messages I get when fiddling with the version and in memory param. It works with true, errors with false.

Ghostscript.NET.GhostscriptAPICallException: An error occured when call to 'gsapi_new_instance' is made: -100 at Ghostscript.NET.Interpreter.GhostscriptInterpreter.Initialize() at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) at Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

* EDIT I've tried downgrading ghost to 9.53.3 and 9.53.1 without any difference.

WilliamDoman commented 2 years ago

The crash debugger utility show's this error when it crashes the app pool.

could not load file or assembly 'gsdll64' or one of its dependencies. The module was expected to contain an assembly manifest.

WilliamDoman commented 2 years ago

We've switched solutions to get past this issue. Thanks

ms0828600 commented 2 years ago

What do you mean with switched solutions - what exactly worked for you now? Thanks