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

net9.0, coreclr.dll exception code: 0xc0000602 #110099

Open
shuijianfeng opened this issue Nov 23, 2024 · 9 comments
Open

net9.0, coreclr.dll exception code: 0xc0000602 #110099

shuijianfeng opened this issue Nov 23, 2024 · 9 comments
Labels
area-VM-coreclr needs-author-action An issue or pull request that requires more info or actions from the author. untriaged New issue has not been triaged by the area owner

Comments

@shuijianfeng
Copy link

Description

Application Name: hcmanagement.exe
• Version: 2.1.0.10
• Timestamp: 0x66f10000
Faulting Module: coreclr.dll
• Module Version: 9.0.24.52809
• Module Timestamp: 0x672049fc
Exception Code: 0xC0000602
Fault Offset: 0x000000000032A356
Process ID: 0x28C8
Application Start Time: 0x01DB3CB3386587E4
Application Path: C:\青山长源软件\青山长源造价系统\hcmanagement.exe
Module Path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.0\coreclr.dll
Report ID: 7596c246-d81b-4054-9e57-de74abc50f1d

Reproduction Steps

using System;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;

using System.Runtime.InteropServices;
namespace hcmanagement
{
static class Program
{
///


/// 应用程序的主入口点。
///

[STAThread]
static void Main()
{

        AssemblyLoadContext.Default.Resolving += ResolveAssembly;
        Process instance = RunningInstance();
        bool bExist = true;
        Mutex mutex = null;
        string mutexName =  "工程管理2.0";

        try
        {
            mutex = Mutex.OpenExisting(mutexName);
            bExist = (mutex == null);

        }
        catch
        {
            mutex = new Mutex(true, mutexName);
        }


        if (!bExist)
        {
            ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL);
            SetForegroundWindow(instance.MainWindowHandle);


        }
        else
        {

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            Application.EnableVisualStyles();
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form1 = new Form1();
            Application.Run(form1);
            form1.Focus();
        }
    }

    private static Assembly ResolveAssembly(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName)
    {
        var probeSetting = AppContext.GetData("SharedsDllsPath") as string;
        if (string.IsNullOrEmpty(probeSetting))
        {
            return null;
        }

        foreach (var subDirectory in probeSetting.Split(';'))
        {
            var pathMaybe = Path.Combine(AppContext.BaseDirectory, subDirectory, $"{assemblyName.Name}.dll");
            if (File.Exists(pathMaybe))
            {
                return assemblyLoadContext.LoadFromAssemblyPath(pathMaybe);
            }
        }

        return null;
    }

    public struct COPYDATASTRUCT
    {

        public IntPtr dwData;

        public int cbData;

        [MarshalAs(UnmanagedType.LPStr)]

        public string lpData;

    }

    [DllImport("User32.dll")]

    private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);

    [DllImport("User32.dll")]

    private static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("User32.dll", EntryPoint = "SendMessage")]

    private static extern int SendMessage(

    int hWnd, // handle to destination window 

    int Msg, // message 

    int wParam, // first message parameter 

    ref COPYDATASTRUCT lParam // second message parameter 

    );

    [DllImport("User32.dll", EntryPoint = "FindWindow")]

    private static extern int FindWindow(string lpClassName, string lpWindowName);

    private const int WS_HIDE = 0;

    private const int WS_SHOWNORMAL = 1;

    private const int WS_SHOWMINIMIZED = 2;

    private const int WS_SHOWMAXIMIZED = 3;

    private const int WS_MAXIMIZE = 3;

    private const int WS_SHOWNOACTIVATE = 4;

    private const int WS_SHOW = 5;

    private const int WS_MINIMIZE = 6;

    private const int WS_SHOWMINNOACTIVE = 7;

    private const int WS_SHOWNA = 8;

    private const int WS_RESTORE = 9;

    public static Process RunningInstance()
    {
        try
        {
            Process current = Process.GetCurrentProcess();
            if (current == null) return null;
            Process[] processes = Process.GetProcessesByName(current.ProcessName);
            if(processes==null)return null;
            //Loop through the running processes in with the same name 

            foreach (Process process in processes)
            {

                //Ignore the current process 
                string mss = process.MainModule.FileName;
                if (process.Id != current.Id)
                {

                    //Make sure that the process is running from the exe file. 

                    if (mss == current.MainModule.FileName)
                    {

                        //Return the other process instance. 

                        return process;

                    }

                }

            }

            //No other instance was found, return null. 

            return null;
        }
        catch 
        {
            return null; 
        }
    }

  
    public static void HandleRunningInstance(Process instance)
    {

        //Make sure the window is not minimized or maximized
        ShowWindowAsync(instance.MainWindowHandle, WS_SHOWMAXIMIZED);

        //Set the real intance to foreground window 

        SetForegroundWindow(instance.MainWindowHandle);

    }
}

}

Expected behavior

In the original net8.0 and below versions, it runs normally

Actual behavior

Under net9.0, errors occur under some win10 and win11 systems

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 23, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 23, 2024
@huoyaoyuan
Copy link
Member

0xC0000602 is STATUS_FAIL_FAST_EXCEPTION, probably by unhandled exception. Is there any stack trace information?

@shuijianfeng
Copy link
Author

0xC0000602 is STATUS_FAIL_FAST_EXCEPTION, probably by unhandled exception. Is there any stack trace information?

net9.0, an error occurs on some customers' win10 and win11 systems, while net8.0 and below versions run normally. Even the simplest net9.0 application will have this error on the system with the error. It runs normally on my PC, so there is no trace information. Thank you very much for your reply

@jkotas
Copy link
Member

jkotas commented Nov 24, 2024

We have seen issues with similar symptoms caused by SentinelOne antivirus software. Could you please check whether the systems where this occurs happen to have SentinelOne software installed?

@jkotas jkotas added area-VM-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 24, 2024
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@huoyaoyuan
Copy link
Member

Could you please check whether the systems where this occurs happen to have SentinelOne software installed?

The particular antivirus software is unlikely to be popular in China market.
Is there instruction to collect dump on customer's machine?

@shuijianfeng
Copy link
Author

We have seen issues with similar symptoms caused by SentinelOne antivirus software. Could you please check whether the systems where this occurs happen to have SentinelOne software installed?

SentinelOne is not installed.

@shuijianfeng
Copy link
Author

Could you please check whether the systems where this occurs happen to have SentinelOne software installed?

The particular antivirus software is unlikely to be popular in China market. Is there instruction to collect dump on customer's machine?

SentinelOne is not installed. There is no dump. In order not to affect the customer's normal work, it is returned to net8.0. It is very inconvenient to debug in the customer's system. Only when other customers make mistakes, debug without affecting their work. Thanks for your reply.

@jkotas
Copy link
Member

jkotas commented Nov 24, 2024

There is no dump.

https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps has instructions for enabling automatic crash dump collection. Could you please try to collect the crash dump of the failure?

I am sorry it is not possible to diagnose the issue from the information provided so far.

@jkotas jkotas added the needs-author-action An issue or pull request that requires more info or actions from the author. label Nov 24, 2024
Copy link
Contributor

This issue has been marked needs-author-action and may be missing some important information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr needs-author-action An issue or pull request that requires more info or actions from the author. untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants