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

w3wp.exe process crashing if AppDomain recycles #218

Closed
victor-mikhalev opened this issue Aug 17, 2023 · 4 comments
Closed

w3wp.exe process crashing if AppDomain recycles #218

victor-mikhalev opened this issue Aug 17, 2023 · 4 comments

Comments

@victor-mikhalev
Copy link

ASP.NET 4.8 application with Net-Vips cause application crash.
Steps to reproduce:

  1. Start app and use Net-Vips library (ex. generate thumbnail)
  2. Recycle AppDomain (rebuild app, deploy, modify web.config etc.)
  3. After process recycles you got exception: Attempted to access an unloaded AppDomain. Threads will hang on generating thumbnails.
    image

Here is sample project to reproduce the issue.
https://github.com/victor-mikhalev/NetVipsCrash

@kleisauke kleisauke added the triage This issue is being investigated label Sep 19, 2023
@kleisauke
Copy link
Owner

I could not reproduce this with IIS Express using the provided sample project.

libvips delays thread creation until it needs them, the first thread is only created when the first pixel is processed. Once it starts processing pixels, it sets up the threading system. As far as I know, recycling the AppDomain should be fine after that (see #164), but trying to use fork() after that point will probably end in disaster.

As a possible solution, you could try to init and shutdown libvips within ASP.NET's Application_Start and Application_End lifecycle functions, for example:
Global.asax:

<%@ Application CodeFile="Global.asax.cs" Inherits="NetVipsCrash.MyApplication" Language="C#" %>

Global.asax.cs:

namespace NetVipsCrash
{
    using System;
    using System.Web;
    using NetVips;

    public partial class MyApplication : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            NetVips.Init();
        }

        void Application_End(object sender, EventArgs e)
        {
            NetVips.Shutdown();
        }
    }
}

However, I'm not sure if this will work.

@kleisauke
Copy link
Owner

@victor-mikhalev Were you able to make any progress with this?

@victor-mikhalev
Copy link
Author

@victor-mikhalev Were you able to make any progress with this?

I have tried your workaround, but it does not help.
I solved the issue by moving NetVips to microservice on .NET Core.

@kleisauke kleisauke removed the triage This issue is being investigated label Jan 14, 2024
@kleisauke
Copy link
Owner

Glad to hear you found a solution to this. I'll close.

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