locked
Application crash 'ucrtbase.dll' RRS feed

  • Question

  • Greetings!

    A few months ago, users of my application faced the error in 'ucrtbase.dll' which leads to termination of the .Net application. Here is the last managed call:

    return Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text);

    This problem is still relevant only for Windows 10 users. As I understand, it is caused due to some unknown object in Clipboard, but I can't tell anything about this object because I still can't reproduce this error.
    Perhaps, this issue is similar to the current:
    https://social.msdn.microsoft.com/Forums/windows/en-US/55815150-a939-4722-bce2-a7beff9627ea/getting-clipboard-data-with-idataobject-s-getdata-crashes-for-enhancedmetafile?forum=winforms

    At present, I added a handler to the 'abort' signal but it is not a fix, just a temporary stub:

    private static void AbortHandler(int signal)

    {
    throw new OperationCanceledException();
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void SignalHandler(int signal);

    [DllImport("ucrtbase.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true, EntryPoint = "signal")]
    private static extern IntPtr SubscribeSignal(int signum, SignalHandler handler);

    static void Main(string[] args)

    {
     SubscribeSignal(20, AbortHandler);

     // more code
    }

    So the question is: will this issue be fixed? Or do I have to make some configuration changes?

    Also, I got two memory dumps from users. Here is the stack trace:

    >	ucrtbase.dll!abort()	Unknown
     	ucrtbase.dll!_purecall()	Unknown
     	ucrtbase.dll!__crt_state_management::wrapped_invoke<int (*)(void),int>(int (*)(void))	Unknown
     	[Inline Frame] combase.dll!CDestObjectWrapper::GetMarshalSizeMax(const _GUID & dwDestCtx=3, void *) Line 565	C++
     	combase.dll!CoGetMarshalSizeMax(unsigned long * pulSize=0x0000002bc4cfdc90, const _GUID & riid={...}, IUnknown * pUnk=0x0000021cfe7e62c0, unsigned long dwDestCtx, void * pvDestCtx=0x0000000000000000, unsigned long mshlflags=0) Line 809	C++
     	clr.dll!wCoMarshalInterThreadInterfaceInStream(struct _GUID const &,struct IUnknown *,struct IStream * *)	Unknown
     	clr.dll!IUnkEntry::MarshalIUnknownToStream(void)	Unknown
     	clr.dll!IUnkEntry::UnmarshalIUnknownForCurrContext(void)	Unknown
     	clr.dll!string "d:\\iso_whid\\amd64fre\\base\\ntos\\r"...()	Unknown
     	clr.dll!RCW::CallQueryInterface(class MethodTable *,class Instantiation,struct _GUID *,struct IUnknown * *)	Unknown
     	clr.dll!RCW::GetComIPForMethodTableFromCache(class MethodTable *)	Unknown
     	clr.dll!ComObject::SupportsInterface(class Object *,class MethodTable *)	Unknown
     	clr.dll!ObjIsInstanceOf(class Object *,class TypeHandle)	Unknown
     	clr.dll!JITutil_IsInstanceOfAny()	Unknown
     	clr.dll!JITutil_IsInstanceOfInterface()	Unknown
     	System.Windows.Forms.ni.dll!00007ffe581b9cdd()	Unknown
     	System.Windows.Forms.ni.dll!00007ffe581b9c79()	Unknown
     	System.Windows.Forms.ni.dll!00007ffe581b9fa9()	Unknown


    • Edited by Oleg Levitsky Tuesday, September 5, 2017 5:25 AM Wrong assembly name for a production fix (ucrtabsed -> ucrtbase)
    Monday, September 4, 2017 1:11 PM

All replies

  • Hi Oleg,

    I'm not sure which dll due to this issue, in your description and the stack trace, the dll is ucrtbase.dll, but you call the ucrtbased.dll, they are different dll.

    As far as I know, the ucrtbase.dll is compiled using maximum optimisation, and ucrtbased.dll is not.

    The ucrtbased.dll carries more/different information than the ucrtbase.dll. They are helping in setting up debug environment.

    And just as you said, the problem is occurred in some users and you can not reproduce this issue, so I guess this is because the dll what users used is not the same as yours, I suggest the following two solution to debug this issue:

    1, You can provide the dll what you used to the user, but can not be guaranteed in terms of security, so it is not recommended.

    2, The best way is debugging your app with the remote desktop control on the user's client.

    Regards,

    Stanly


    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.

    Tuesday, September 5, 2017 3:24 AM
  • 'ucrtbaseD.dll' is just for debugging. I made a custom build for a few users using 'ucrtbase.dll' (without 'd') and everything works fine (at least for a few days).

    In case of remote debugging, I will see the same stack and the same issue - CLR can't convert some COM object in Clipboard to managed data due to the unhandled exception.

    Also, I asked about the version of this library - it's the same as on my PC.

    Tuesday, September 5, 2017 5:56 AM
  • Hi Oleg Levisky,

    >> CLR can't convert some COM object in Clipboard to managed data due to the unhandled exception.

    1. When you debug the application, do you use the remote debug tools or debug in remote desktop?If you use remote debug tools, maybe you need more permissions. 
    2. For the error message, we could not get what is the unhandeled exception. According to your feedback, the build for few users using "ucrtbase.dll" works fine. Have you do any update for Windows or system? 
    3. Does the users has the same system opreration with the same dll version as yours? 

    Best Regards,

    Wendy


    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.


    Thursday, September 7, 2017 6:44 AM
  • Hi, Wendy!

    >When you debug the application, do you use the remote debug tools or debug in remote desktop?If you use remote debug tools, maybe you need more permissions.
    I'm "debugging" a dump file. I'd like to use Remote Debugger or Team Viewer + Visual Studio on remote PC, but I don't have steps to reproduce this bug.

    > For the error message, we could not get what is the unhandeled exception.
    I can provide the required information. Will it be helpful for you?  https://www.dropbox.com/s/07uy0dm6f9itz9p/Unhandled.png?dl=0

    > According to your feedback, the build for few users using "ucrtbase.dll" works fine. Have you do any update for Windows or system?
    No, I haven’t. Users replied that all available updates were installed.

    > Does the users has the same system opreration with the same dll version as yours?
    As I know, yes. Windows 10 + ucrtbase.dll 10.0.15063.413 (WinBuild.160101.0800)

    Thursday, September 7, 2017 9:37 AM
  • Hi Oleg Levitsky,

    When you debug the dump file, according to the stack trace you provided in your question description, you may miss the symbols. The information from the stack trace, most of them shows Unknown.  Please refer to the following link to provide the details when you debug the dump file.

    https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-managed-code

    >>'ucrtbaseD.dll' is just for debugging. I made a custom build for a few users using 'ucrtbase.dll' (without 'd') and everything works fine (at least for a few days).

    When users using "ucrtbase.dll" and everything works fine? Before update the windows or systems? Does the dll works fine before and then does not work?

    Best Regards,

    Wendy


    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.

    Monday, September 11, 2017 7:56 AM
  • Hi Wendy! Thanks for reply!

    >When users using "ucrtbase.dll" and everything works fine?
    There was only one kind of fix - using the abortion handle for "ucrtbase.dll". The code above still works fine.

    >Before update the windows or systems?
    In all cases, all available updates were installed and this issue is still relevant for today.

    >Does the dll works fine before and then does not work?
    I've never used 'ucrtbase.dll' directly from my code before, only the 'Clipboard.ContainsText' method. So, in common, yes, 'ucrtbase.dll' worked fine before.

    >Debugging Managed Code Using the Windows Debugger
    I've got 'Server Error in '/' Application.' when I tried to download 'Windows Driver Kit'. I will try to download it later.
    Monday, September 11, 2017 9:16 AM
  • Hi Oleg,

    I have written code using Clipboard.ContainsText(). I copied text, file and folder, no exception or crash. So I want to know the scenario of your question. What operation did your user do before crash?

    What's more, the dump you post here is the crash dump?

    Best Regards,

    Charles He


    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.


    Thursday, September 14, 2017 10:01 AM
  • >I have written code using Clipboard.ContainsText(). I copied text, file and folder, no exception or crash.
    Yes, I know. That's why I still can't reproduce this issue.

    >So I want to know the scenario of your question. What operation did your user do before crash?
    I have no idea. I've asked about the Clipboard content and one of the users sent me the following text:
    style="height:300px;"
    That's it.

    >What's more, the dump you post here is the crash dump?
    Of course.
    Thursday, September 14, 2017 11:38 AM
  • Hi Oleg,

    We still don't have enough information to fix your app. I wonder if you are willing to share the crash dump with us.

    By the way, have you reproduced the scenario? 

    Best Regards,

    Charles He


    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.




    Monday, September 18, 2017 6:43 AM
  • Hello!

    > By the way, have you reproduced the scenario?
    Unfortunately no

    Here is the dump file:
    https://www.dropbox.com/s/tib3ugin16o77zm/CrashDump.dmp?dl=0
    Monday, September 18, 2017 3:15 PM
  • Hello! Do you have any news?
    Monday, September 25, 2017 12:34 PM
  • Hi! I am still waiting for answer or suggestion. Please let me know if I can provide more information
    Tuesday, October 10, 2017 6:07 AM
  • Hi Oleg,

    I am involving someone else who is more experienced to help you. Please provide your Visual Studio version and your customer's windows version(windows 10 home or windows 10 enterprise or else) to make the question specific.

    Best Regards,

    Charles He


    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.


    Tuesday, October 10, 2017 7:47 AM
  • Hello!
    My VS version is: 14.0.2543.01 Update 3
    Used MS build version (on build server): 14.0.25420.1
    Customer Windows version: Windows 10 Enterprise Build 14393.639
    One more Windows version: Windows 10 Enterprise Build 14393.1066
    Wednesday, October 11, 2017 9:16 AM
  • Hi! Do you have any news?
    Users still report about this bug
    Thursday, October 26, 2017 5:00 AM
  • Hi Oleg,

    Sorry to delay. I have involved someone else who is more experienced to help you. We also involved other resources to figure out the route cause. However, there is still not enough information in your dump file for them to fix the problem.

    Please visit the below link to see the various free and paid support options that are available to meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Best Regards,

    Charles He


    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.


    Tuesday, October 31, 2017 7:09 AM
  • HI,

    We have exactly the same problem here with our app. Same .Net code Clipboard.ContaintText(), Same error CLR can't convert some COM object in Clipboard to managed data due to the unhandled exception  and same call stack .abort() in ucrtbase that appear randomly in ucrtbase.dll 10.0.15063.674 on windows 10. Any news or fix?.

    Mike

    Wednesday, November 1, 2017 12:15 PM
  • Hello Charles!
    I sent everything I've got. Which kind of information will help to solve this issue? Maybe one more dump or something else...
    Friday, November 3, 2017 6:34 AM
  • Hi, Mike!

    Well, welcome to the club, sir. Do you have any info about this mysterious COM object?

    Friday, November 3, 2017 6:34 AM
  • Hi Oleg,

    I know you sent everything you know already. Thanks for your cooperation.

    I have ask other support engineers(not for community) for help. However, what I got from them is that there is still not enough information in your dump file.

    I recommend you follow the link I have given to access our one-to-one support(not terminology but easy to understand I think). Our support engineers will help you with e-mails or telephone directly. This way is more efficient and explicit. They will ask for your cooperation to get information they need and finally help you fix your problem.

    By the way, is this thread also created by you?

    Best Regards,

    Charles He


    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.


    Friday, November 3, 2017 6:52 AM
  • No, I don't have any clue about which COM object cause the problem.
    Monday, November 6, 2017 12:01 PM
  • Hi Oleg, did you fix this problem? I have this issue at my own application as well.

    Thanks!

    Wednesday, April 18, 2018 5:33 PM
  • Hi, dear reyou!

    In common - no, I am not.

    But, I've created a stub - an utility method, which wraps a call of the 'Clipboard.ContainsData'. Inside this method I am verifying an OS version and if current version is Windows 10 - method will not call 'ContainsData'.

        public static bool CanPasteDataFromClipboard(params string[] dataFormats)
        {
    
          bool isWindows10 = Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10;
    
          if (isWindows10)
            return true; // my stub
    
          foreach (var format in dataFormats) {
            try {
              if (Clipboard.ContainsData(format))
                return true;
            }
            catch {
              continue;
            }
          }
    
          return false;
        }

    Do you know how to reproduce this issue?

    Thursday, April 19, 2018 6:24 AM
  • Hi Oleg,

    For my case, I have a WinForms application, and this application has a Timer running for every 3 seconds, and reads Clipboard text, and appends into a file if Clipboard content changes. Don't ask why :) This is just a requirement. In normal case scenario I do not have any issue. But, while application is running, if I open a Visual Studio 2017 instance, and code around, and copy/paste some text, it crashes with error in the title. 

    Probably Visual Studio accesses to Clipboard and doing some weird things, and it conflicts with my application Clipboard access, and ucrtbasedll throws critical exception, even my managed try/catch block cannot handle.

    Not sure what is happening in that dll, and not sure how to handle that critical error.

     
    void TimerClipboardTick(object sender, EventArgs e)  {      
     try       {        
      // string text = Clipboard.GetText();                
      string text = "";        
      IDataObject dataObject = Clipboard.GetDataObject();        
      if (dataObject != null)         {          
       using(MemoryStream data = (MemoryStream) dataObject.GetData("text"))           {            
        if (data != null)             {              
         using(StreamReader reader = new StreamReader(data))               {                
          text = reader.ReadToEnd();              
         }            
        }          
       }        
      }
     } catch (Exception exception)       {        
      textBoxLastError.Text = exception.Message;      
     }
    }

    Thursday, April 19, 2018 1:51 PM
  • can pleas explain more about how to add this code , 

    private static void AbortHandler(int signal)

    {
    throw new OperationCanceledException();
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void SignalHandler(int signal);

    [DllImport("ucrtbase.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true, EntryPoint = "signal")]
    private static extern IntPtr SubscribeSignal(int signum, SignalHandler handler);

    static void Main(string[] args)

    {
     SubscribeSignal(20, AbortHandler);

     // more code
    }

    when i add i got this message , it's not alowed to use here , so may u explain where exactly shall I add it thanks a lot

    Friday, April 20, 2018 7:31 AM
  • Hi reyou!

    Yep, looks same with my case. I am still have no idea how to handle this exception. My attempt to add custom AbortHandler does not work :(

    It's weird that I can't reproduce it - I am using VS 2017 too. Is it possible that some extension to VS causes this?

    Friday, April 20, 2018 7:38 AM
  • Hello,

    we got this problem as well. The solutions posted so far ar not helping. its crashing all over the place as soon as something from visual studio is inside clipboard.

    I downloaded a clipboard viewer to erase the entire clipboard when im starting our app to be sure the clipboard is empty. The crashes only happen with stuff inside the clipboard from within visual studio.

    using

    Visual Studio 2017 version 15.7.3

    Wednesday, June 6, 2018 9:45 AM
  • Hi, Snoelk!

    Could you please tell what kind of data should be placed in clipboard to reproduce this bug?

    Thursday, June 7, 2018 8:19 AM
  • hello,

    just got a crash example while got an enum inside clipboard.

    since my account is not verified or whatever that means i can't post links or screenshots of the clipboard content.

    is there another way to show it somehow?


    Wednesday, June 13, 2018 12:27 PM
  • Hello,

    You cant post a link as plain text

    Wednesday, June 13, 2018 5:12 PM
  • ok, here a link to a 7zip file which contains the Free Clipboard Viewer 3.0 clipboard content and the screenshots of all the content if you don't got this tool.

    http://gst.piranha-bytes.com/crash/ucrtbase_clipboard_crash.7z

    Thursday, June 14, 2018 7:46 AM
  • When the ucrtbase.dll file is your culprit its time to either 1) Reimage your machine or 2) Run a SFC/scannow in command prompt(elevated creds) to hope it can be fixed with a working cached copy. If not you will continue to run into the error.

    • Proposed as answer by Suntaurus Wednesday, November 27, 2019 11:51 AM
    • Unproposed as answer by Suntaurus Wednesday, November 27, 2019 11:51 AM
    Thursday, October 18, 2018 10:07 PM
  • I too had similar issue and it is something to do with visual studio handling clipboard.

    However, I handled this in my code by writing a Clipboard Listener and reading the clipboard on only when something is placed on it instead of querying all the time.

    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace Utilities
    {
       public abstract class ClipboardManager
       {
          private static readonly ClipboardListener _Listener;
          private static string _Text;
          private static bool _HasText;

          public static string Text { get { return _Text; } }
          public static bool HasText { get { return _HasText; } }

          private class ClipboardListener : NativeWindow
          {
             private readonly Action _Action;

             private const int HWND_MESSAGE = -3;
             private const int WM_CLIPBOARDUPDATE = 0x031D;

             [DllImport("user32.dll", SetLastError = true)]
             [return: MarshalAs(UnmanagedType.Bool)]
             private static extern bool AddClipboardFormatListener(IntPtr hWnd);


             [DllImport("user32.dll", SetLastError = true)]
             [return: MarshalAs(UnmanagedType.Bool)]
             private static extern bool RemoveClipboardFormatListener(IntPtr hWnd);

             protected override void WndProc(ref Message m)
             {
                base.WndProc(ref m);
                if (m.Msg == WM_CLIPBOARDUPDATE)
                   _Action.Invoke();
             }

             protected override void OnHandleChange()
             {
                base.OnHandleChange();
                AddClipboardFormatListener(this.Handle);
             }

             public override void DestroyHandle()
             {
                RemoveClipboardFormatListener(this.Handle);
                base.DestroyHandle();
             }

             public ClipboardListener(Action action)
             {
                _Action = action;
                _Action.Invoke();

                this.CreateHandle(new CreateParams { Parent = new IntPtr(HWND_MESSAGE) });
             }
          }

          private static void OnUpdate()
          {
             _HasText = Clipboard.ContainsText();
             _Text = _HasText ? Clipboard.GetText() : string.Empty;
          }

          static ClipboardManager()
          {
             _Listener = new ClipboardListener(OnUpdate);
          }
       }
    }


    • Edited by Suntaurus Wednesday, November 27, 2019 12:03 PM
    Wednesday, November 27, 2019 11:54 AM
  • Hello,

    We have a similar problem with our product running on two Windows 10 machines. I intercepted the running application with remote debugger, obtained stack trace and even watched one internal parameter (the queried class ID - IMarshal). This may be useful some day if MS people would want to look for the problem in the code.
    The stack trace includes only Windows part, our app just calls GetDataObject().

    Windows version: 10.0.17134.1130.

    upd: it seems to happen only on faster machines but I'm not quite sure. Our app calls GetDataObject() in Application.Idle event handler (i.e. very fast), to update the status of the Paste toolbar button.

     	ucrtbase.dll!_abort()	Unknown
     	ucrtbase.dll!__purecall()	Unknown
     	ucrtbase.dll!__crt_state_management::wrapped_invoke<int (__cdecl*)(void),int>()	Unknown
    >	combase.dll!CStdIdentity::CInternalUnk::QueryMultipleInterfacesLocal(unsigned long cMQIs=1, tagMULTI_QI * pMQIs=0x0c8ecc3c, tagMULTI_QI * * ppMQIPending=0x0c8ecbf0, _GUID * pIIDPending=0x0c8ecbe0, unsigned long * pcAcquired=0x0c8ecc14) Line 638	C++
     	combase.dll!CStdIdentity::CInternalUnk::QueryMultipleInterfaces(unsigned long cMQIs=1, tagMULTI_QI * pMQIs=0x0c8ecc3c) Line 702	C++
     	combase.dll!CStdIdentity::CInternalUnk::QueryInterface(const _GUID & riid={...}, void * * ppv=0x0c8eccbc) Line 423	C++
     	combase.dll!IUnknown_QueryInterface_Proxy(IUnknown * This=0x0b0bc96c, const _GUID & riid={...}, void * * ppv=0x0c8eccbc) Line 1707	C++
    -		riid	{IID_IMarshal}	const _GUID &
    		Data1	3	unsigned long
    		Data2	0	unsigned short
    		Data3	0	unsigned short
    +		Data4	0x74a8afcc "À"	unsigned char[8]
     	ole32.dll!CClipDataObject::QueryInterface(const _GUID & riid={...}, void * * ppvObj=0x0c8eccbc) Line 884	C++
     	combase.dll!CDestObjectWrapper::MarshalInterface(IStream * pStm=0x0d3736d8, const _GUID & riid={...}, void * pv=0x0d528f20, unsigned long dwDestCtx=3, void * pDestObjectWrapper=0x0c8ece08, unsigned long mshlflags=0) Line 701	C++
     	combase.dll!CoMarshalInterface(IStream * pStm=0x0d3736d8, const _GUID & riid={...}, IUnknown * pUnk=0x0d528f20, unsigned long dwDestCtx=3, void * pvDestCtx=0x00000000, unsigned long mshlflags=0) Line 1074	C++
     	[Managed to Native Transition]	
     	System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject(int retryTimes, int retryDelay)	Unknown
     	System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject()	Unknown



    Tuesday, December 17, 2019 5:18 PM
  • Could you elaborate? I think this is on the right path, but I'd like to know more!
    Wednesday, February 26, 2020 10:27 PM