Search Unity

Bug Dedicated Server exe not shutting down on Unity 2021.3

Discussion in 'Scripting' started by BenjaminSimsMK, May 18, 2022.

  1. BenjaminSimsMK

    BenjaminSimsMK

    Joined:
    May 5, 2021
    Posts:
    1
    After upgrading from Unity 2020 to 2021.3 we're finding that our servers are no longer shutting down after calling Application.Quit. This is causing issues with our server hosting as it can't detect that the application has terminated, and the VM never shuts down. (Our builds before updating Unity worked perfectly)

    After some debugging, it seems to get stuck in a loop of calling RtlExitUserThread, which uses NtQueryInformationThread(ThreadAmILastThread) to see if it's the last thread, then if it's not, it terminates the thread, otherwise it terminates the process.

    But it's constantly calling this on the main thread and it's never the last thread so it keeps trying (and I guess failing) to terminate the main thread.

    We're using async/await in a few places, I was wondering if this could be related, however we did not have any issues in the previous Unity version.

    Has Unity changed anything about how it handles Application.Quit, or terminating background threads when the application exits?

    If there are any suggestions on what we could do to fix the problem that would be great. I don't have time to make a repo project at this stage and make a bug report unfortunately.