ClaRun.dll error intermittent Exception Code: 0xc000041d

Hi,

We have moved our application from C6 to C11. But sometime (not always) the application crashed. And the error message shows it is with the ClaRun.dll (exception code: 0xc000041d).

Does anyone know what cause it and how to fix it?

Thanks,

Louie

Are all of the Clarion DLLs in your app folder compiled with the same Clarion version? What about 3rd party?

This is a good place to start to get more information:

Yes, I have copied the Clarion DLLs from the bin folder. And the 3rd party’s DLLs from Accessory/bin.

Thanks Jane, I will try the suggestion.

As @Jane said be sure to setup debug and use the .\Debug\ClaRun.dll so you get a call stack with symbols to at least have an idea that last place in Your Code that ran before the RTL call that failed.

It may help to see the entire window in your screen capture. The Exception code: 0xc000041d is the best clue you have, search for that. One of man I found:

Exception 0xC000041D means that an unhandled exception was encountered during a user callback. It means that 0xC000041D is a second chance exception. So we should capture the first chance exception ,if we want to know the root cause. Usually it’s occurred in system defined callback context on Windows, for example message handling context. And customized callback will not throw the exception

Maybe running under the Clarion Debugger it would happen and you could see the call stack.

Dependency Walker has a profiling feature that may show you the first exception. That probably will not be too helpful since it will not tell you in terms of your code.

Clarion LastChanceHook lets you get the exception log always. What I do with it is call ICWExceptionInfo.LogException() to always write a log without having to push a button, then I still show a window but that’s optional.

Here’s some code I use

INCLUDE('CWEXCPT.INT'),ONCE
MAP  
  HookExceptionLastChance(*ICWExceptionInfo ExInfo),LONG 
  MODULE('Win32')
       MsgBx4Hook(UNSIGNED hWnd, CONST *CSTRING cText, CONST *CSTRING cCaption, UNSIGNED uType),SIGNED,PROC,PASCAL,NAME('MessageBoxA'),DLL(1)
  END 

LastChanceHookCls     CLASS           !DecSysException.TPW  
CONSTRUCT               PROCEDURE()   !Sets Hook to HookExceptionLastChance
HookOriginal            LONG          !Original RTL Address to allow restore
TakeInfo                PROCEDURE(*ICWExceptionInfo _ExInfo)
ExCode                  STRING(8)
ExAddr                  STRING(8)
Hex                     PROCEDURE(LONG Lng),STRING
                      END

!----------------------------------------------------------
HookExceptionLastChance PROCEDURE(*ICWExceptionInfo ExInfo)
cMsgText    CSTRING(512),AUTO
cMsgCap     CSTRING(48),AUTO
uMsgType    UNSIGNED(0+10h)       !Ok + Hand Icon
ExcptLogFN  CSTRING(261),AUTO
  CODE
  IF ExInfo &= NULL
    RETURN 0
  END
  ExcptLogFN='Ignore (Resume)' ; ExInfo.ContinueButton(ExcptLogFN)  !Rename 'Continue' button 'Ignore'
  ExcptLogFN = LONGPATH()&'\EXCEPTION-' & FORMAT(TODAY(),@D11) &'-' & FORMAT(CLOCK(),@T05)&'.LOG'
  ExInfo.LogException(ExcptLogFN)     !Write the log to disk now before the message so always have it
  LastChanceHookCls.TakeInfo(ExInfo)  !Class to deal with ExInfo
  cMsgText = 'An unexpected problem has caused an Exception 0x' &  LastChanceHookCls.ExCode &'.'&|
            ' A log file of this problem has been written to the below file:'&|
            '<13,10><13,10>'&ExcptLogFN&|  !
            '<13,10><13,10>Please note the log file name and recent steps you took in the program.' & |
            ' For assistance with this error contact Tech Support.' & |
            '<13,10><13,10>Click OK and detailed error information will be displayed.'
  cMsgCap = 'Program Exception 0x' & LastChanceHookCls.ExCode &' at ' & LastChanceHookCls.ExAddr
  MsgBx4Hook(0,cMsgText,cMsgCap,uMsgType)    !Use API MessageBox to avoid calls into RTL that may be corrupt
  RETURN 0                                   !Zero shows RTL Exception Window will full call stack

LastChanceHookCls.CONSTRUCT    PROCEDURE()   !Sets Hook to HookExceptionLastChance at program start when Constructor fires
  CODE
  IF ~SELF.HookOriginal THEN SELF.HookOriginal=SYSTEM {PROP:LastChanceHook}.
  SYSTEM{PROP:LastChanceHook}=ADDRESS(HookExceptionLastChance)
  RETURN
LastChanceHookCls.TakeInfo                PROCEDURE(*ICWExceptionInfo _ExInfo)
    CODE
    SELF.ExCode = SELF.Hex(_ExInfo.ExceptionCode())
    SELF.ExAddr = SELF.Hex(_ExInfo.ExceptionAddress()) 
    RETURN 
LastChanceHookCls.Hex                     PROCEDURE(LONG A)!,STRING
i       UNSIGNED,AUTO
S       STRING(8),AUTO
DIGITS  STRING('0123456789ABCDEF')
  CODE
  LOOP i=8 TO 1 BY -1 ; S[i] = DIGITS[BAND (A, 0Fh) + 1] ; A = BSHIFT (A, -4) ; END
  RETURN S

Might be good to ensure all 3rd party dlls are actually compiled in the correct version

Thanks for your help. We are trying to use GPF Reporter to debug. We will try your suggestion if we could not find the reason by using GPF reporter.