none
clr.dll error cause stop my service RRS feed

  • Вопрос

  • I made a windows service project named "WindowsService-DS".

    Then I run it on more than one computer. Then some of them will stop my service with an error, the error modle is "clr.dll" and error code is "c0000005".

    It is strange that only three computer have the error. And I can only find "ntdll.dll" error from the system dump file. I have tryied to  restore donet library,but it is not work. "clr.dll" file version is 4.0.30319.17929

    It have occured 5 times on three computer, and i have no idea. 

    Look forward to your reply

Все ответы

  • Nearly all "access violation" (0xc0000005) comes from clr.dll because that's where the resource manager (responsible for garbage collection) is running at. Without any dump file, there couldn't be any guess on what caused the fault.

    Either try to hook up debugger on those affected machines to debug, or carefully evaluate your unmanaged resources usage and see if that's any chance that you accidentially freed something before using it.

    Отвечающий
  • Hi morlongxing,

    How is the question going? Please let me know if you need further assistance.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Модератор
  • Sorry have no reply for a long time.

    As cheng00 said, I annotating "GC.Collect" code in my program ,but it sames that it not work. 

    Another question: my program is "debug"version , is it may cause this problem?

    Best Regards

    12 июня 2020 г. 5:26
  • No. What I was saying is that "clr.dll" is only the scapegoat of improper-paired allocation/free code or race conditions. The problem is in the logic of your code. Therefore without code we can't possibly tell you want the reason is.

    "Either try to hook up debugger on those affected machines to debug, or carefully evaluate your unmanaged resources usage and see if that's any chance that you accidentially freed something before using it." is telling you a few possible items to check if you're unable to give us code that can show the problem.


    12 июня 2020 г. 5:53
    Отвечающий
  • For completeness's sake, this article featured in MSDN Newsletter have walk-through on how to generate dump file and use Visual Studio to analyse the dump.
    16 июня 2020 г. 3:52
    Отвечающий
  • Thank you for suggestion

    I have used ProcDump and catch a dump. I open it in VS2017 ,but do not find any wrong in my code. Following is a code of debuging.   

    the wrong code is the 8th line: "string[] strArray =  regex.Split(msg.CCP);"  and msg.CCP is a string.

    private bool MatchCCP(CCPRec msg,out MsgSend2DF msgSend)
            {
                msgSend = new MsgSend2DF();
                msgSend.msgId = msg.msgID;
                try
                {
                    Regex regex = new Regex("TIMEOUT");
                    string[] strArray =  regex.Split(msg.CCP);
                    if (strArray.Count()==2)
                    {
                        int timeOut =Convert.ToInt32( strArray[1]);
                        string[] detect = strArray[0].Split(' ');
                        string[] ccpStruct;
                        if (Str2CCPStr(detect, out ccpStruct))
                        {
                            msgSend.msgId = msg.msgID;
                            msgSend.deviceName = ccpStruct[0];
                            msgSend.deviceCmd = ccpStruct[1];
                            msgSend.timeOut = timeOut;
                            if (ccpStruct.Count() > 2)
                            {
                                msgSend.param = new string[ccpStruct.Count() - 2];
                                for (int i = 2; i < ccpStruct.Count(); i++)
                                {
                                    msgSend.param[i - 2] = ccpStruct[i].Trim('"');
                                }
                            }
    						return true;
    
    					}
                        else
                            return false;
                    }
                    else if(strArray.Count()==1)
                    {
                        int timeOut = 3600000;
                        string[] detect = strArray[0].Split(' ');
                        string[] ccpStruct;
                        if (Str2CCPStr(detect, out ccpStruct))
                        {
                            msgSend.msgId = msg.msgID;
                            msgSend.deviceName = ccpStruct[0];
                            msgSend.deviceCmd = ccpStruct[1];
                            msgSend.timeOut = timeOut;
                            if (ccpStruct.Count() > 2)
                            {
                                msgSend.param = new string[ccpStruct.Count() - 2];
                                for (int i = 2; i < ccpStruct.Count(); i++)
                                {
                                    msgSend.param[i - 2] = ccpStruct[i].Trim('"');
                                }
                            }
    						return true;
    					}
                        else
                            return false;
                    }
                    else
                    {
                        Utility.LogControl.Error("CCP format error");
                        string error = ErrorManager.ErrorInterface.GetErrorCode(ErrorLevel.Error, classCode, (byte)SoftCommond.MatchCCP, ErrorCause.CCPExcudeError);
                        ErrorManager.ErrorInterface.SendErrorMsg(error);
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    Utility.LogControl.Error(ex.ToString());
                    string error = ErrorManager.ErrorInterface.GetErrorCode(ErrorLevel.Error, classCode, (byte)SoftCommond.MatchCCP, ErrorCause.CCPExcudeException);
                    ErrorManager.ErrorInterface.SendErrorMsg(error);
                    return false; ;
                }  
            }

  • 名称 类型
    msg {CommunicationData.CCPRec} CommunicationData.CCPRec
    CCP "WEIGHT01 GET TIMEOUT 1000" string
    msgID "85421!BlockResult" string
    msg.CCP "WEIGHT01 GET TIMEOUT 1000" string
    this {DataInterface.ZMQ} DataInterface.ZMQ
    ▶ CCPRec {NetMQ.Sockets.ResponseSocket} NetMQ.NetMQSocket {NetMQ.Sockets.ResponseSocket}
    ▶ CCPSend {NetMQ.Sockets.PushSocket} NetMQ.NetMQSocket {NetMQ.Sockets.PushSocket}
    classCode 157 byte
    isInit true bool
  • 名称 类型
    $exception {"Exception of type 'System.ExecutionEngineException' was thrown."} System.ExecutionEngineException
    this {DataInterface.ZMQ} DataInterface.ZMQ
    ▶ CCPRec {NetMQ.Sockets.ResponseSocket} NetMQ.NetMQSocket {NetMQ.Sockets.ResponseSocket}
    ▶ CCPSend {NetMQ.Sockets.PushSocket} NetMQ.NetMQSocket {NetMQ.Sockets.PushSocket}
    classCode 157 byte
    isInit true bool
    ▶ Static members
    msg {CommunicationData.CCPRec} CommunicationData.CCPRec
    CCP "WEIGHT01 GET TIMEOUT 1000" string
    msgID "85421!BlockResult" string
    msgSend {DataInterface.MsgSend2DF} DataInterface.MsgSend2DF
    deviceCmd null string
    deviceName null string
    msgId "85421!BlockResult" string
    @param null string[]
    timeOut 0 int
  • You may want to expand the $exception to see what the .Message says, and whether it contain inner exception that will tell you more.

    ExecutionEngineException just mean there is some internal error occurred in execution engine of the CLR.

    1 июля 2020 г. 15:35
    Отвечающий
  • it sames that can not find inner exception in $exception

    名称 类型
    $exception {"Exception of type 'System.ExecutionEngineException' was thrown."} System.ExecutionEngineException
    ▶ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
    HResult -2146233082 int
    HelpLink null string
    ▶ IPForWatsonBuckets 0x0000000000000000 System.UIntPtr
    ▶ InnerException null System.Exception
    IsTransient false bool
    Message "Exception of type 'System.ExecutionEngineException' was thrown." string
    RemoteStackTrace null string
    Source null string
    StackTrace null string
    TargetSite null System.Reflection.MethodBase
    WatsonBuckets null object
    _HResult -2146233082 int
    _className "System.ExecutionEngineException" string
    ▶ _data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
    _dynamicMethods null object
    _exceptionMethod null System.Reflection.MethodBase
    _exceptionMethodString null string
    _helpURL null string
    ▶ _innerException null System.Exception
    ▶ _ipForWatsonBuckets 0x0000000000000000 System.UIntPtr
    _message null string
    _remoteStackIndex 0 int
    _remoteStackTraceString null string
    ▶ _safeSerializationManager null System.Runtime.Serialization.SafeSerializationManager
    _source null string
    _stackTrace null object
    _stackTraceString null string
    _watsonBuckets null object
    _xcode -532462766 int
    ▶ _xptrs 0x0000000000000000 System.IntPtr
    ▶ Static members

  • No luck to see what happened then.

    You may want to check if those machine having this problem are running older version of .NET framework runtime, to deduce whether recommending update can fix the problem.

    ======

    Normally I would suggest you to try replace Regex.Split() with String.Split() and see if you can get rid with that, but the nature of EngineExecutionException suggest that maybe replacing it will just postpone the problem.

    You can still do that though as it shouldn't harm anything.

    Отвечающий