Filter from SetUnhandledExceptionFilter not capturing C++ exceptions from threads started with _beginthread on windows server 2022

Anonymous
2024-09-11T00:50:49+00:00

We have found a the change in behaviour of the SetUnhandledExceptionFilter API call.
On windows server 2016, this enables any uncaught C++ exceptions to be handled by a registered filter, including on our worker threads.
In our filter callback we have alternative handling, including stopping the applications from terminating,
but on windows server 2022, our filter doesn't get called for C++ exceptions on our worker threads, but the application is terminated instead.

There is no mention of a change in behaviour of this on certain windows versions in the windows API documentation

Some investigation has shown this seems to be related to different versions of UCRT.dll (universal C run time) between different windows server OS versions.
And also in relation to any threads created using _beginthread/_beginthreadex
It seems this has been changed to _beginthread to now be noexcept() in behaviour - similar to std::thread behaviour.
But the problem is that this is not based which version of the C++ compiler/toolset or C/C++ libraries that we compile/link against, but what the OS shipped UCRT.DLL is compiler against, and so relates to the windows OS version.

We are needing to upgrade some servers to windows server 2022 from 2016, but this is changing the behaviour of out existing applications, that rely on the SetUnhandledExceptionFilter behaviour to catch any C++ exceptions.
And so this is blocking our migration.
This applications need to be running continually (except for allowed shutdown times on weekends), and so crashes/shutdown are major incidents.

Windows Server Remote and virtual desktops

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes
Accepted answer
  1. Anonymous
    2024-09-11T01:08:47+00:00

    Hello,

    Thank you for posting in Microsoft Community forum.

    From the description above, I understand your question is related to C++ & API.

    Since there are no engineers dedicated to this topic in this forum. To be able to get a quick and effective handling of your issue, I recommend that you repost your question in the Q&A forum, where there will be a dedicated engineer to give you a professional and effective reply.

    Here is the link for Q&A forum.
    Questions - Microsoft Q&A

    Click the "Ask a Question" button in the upper right corner to post your question and select tags related to your products.

    I hope the information above is helpful.

    If you have any questions or concerns, please feel free to let us know.

    Regards, Karlie

    0 comments No comments

0 additional answers

Sort by: Most helpful