locked
Clipboard.Clear plus a right click on the desktop causes crashes in explorer.exe and mmc.exe RRS feed

  • Question

  • This is on Windows 7 64 bit.  Create an empty Winforms app, add this line anywhere:

    Clipboard.Clear();

    Compile, execute, close. You can also download a small exe from here: ClipboardClear app.

    After you run the exe, when you right click on the desktop, the explorer memory gets corrupted, and the explorer will crash soon after. Opening and closing explorer windows two or three times triggers the crash.

    This is probably also what Firefox does in private mode after you close it, as some people have reported here.

    If you enable Full-page heap for explorer.exe, the moment of the right click is when the access violation happens. When the cliboard is empty, event viewer will also crash.

    Tuesday, August 10, 2010 6:12 AM

Answers

  • Hi,

    From your description, I noticed that the issue is not caused by Windows 7 system issues, but related to the source code. Since this forum is for Windows 7 technical questions, you may not be able to obtain useful information here. I suggest you discuss in our MSDN forum.

    Windows Native Development Forums


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    • Marked as answer by Arthur Xie Friday, August 20, 2010 9:51 AM
    Monday, August 16, 2010 3:31 AM

All replies

  • No, works here fine on my Windows 7 Ultimate.
    "A programmer is just a tool which converts caffeine into code" CLIP- Stellvertreter http://www.winvistaside.de/
    Tuesday, August 10, 2010 2:55 PM
  • I suggest you troubleshoot in Clean Boot Mode.

    Perform a clean startup to determine whether background programs are interfering with your game or program 

    If the issue persists in Clean Boot Mode, I suggest you try ShellExView.

    Important Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

    Run ShellExView, in the pane sort the entries with manufacturers. Disable all non-Microsoft *.dll files, and check the result. If the issue does not occur, one of the files can be the culprit. We could narrow down it one by one.

    Additionally, are you sure that the program works well on other computers?

    Also please let us know if this program can run in Safe Mode. If so, please let us know if it works properly in Safe Mode.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    Thursday, August 12, 2010 7:09 AM
  • Hello there, thanks for your suggestions.

     

    This is the same issue, as discussed here:

    https://bugzilla.mozilla.org/show_bug.cgi?id=518412

     

    This is the interesting part:

    "Our Microsoft contacts have confirmed this to be a bug on the Windows clipboard handling code, and have suggested a couple of workarounds for us, until they get the problem fixed on their side."

     

    Since my application was causing this crash, I changed the trouble causing line, which happens to be Clipboard.Clear().  I've also created the minimal code that will trigger this, and it happens to be a one liner, more precisely a single call.   You can download this app and try it for yourself.  Windows 7, 64 bit.   Start the app, right click on the desktop, at this point the memory of your explorer is corrupted and it will crash sometimes later (or right away).  Yes, it also crashes the explorer if you start windows in safe mode.

     

    You seem to have MSFT by your name, I assume you work for MS, can you confirm that that MS knows about this, or that this has already been fixed and is waiting for the SP1?   I guess this is the only way you can help since crushes are gone on my computer.

     

    I also have a strong suspicion that this causes not just explorer.exe crashes, but corrupts memory of all processes that handle clipboard in some way.   Explorer just being most exposed to this, or releasing memory most aggressive.   Since I had random application failures on basically all other programs I use, including excel, visual studio, and others, all programs I have been using for 3 years on the same hardware.  Since I replaced the Clipboard.Clear line 3-4 days agao, nothing crashed, and there is a chance that those could have been caused by the same problem.  So, this could be a bigger issue than just explorer restarts...

     

     

     

    Thursday, August 12, 2010 7:58 AM
  • Hi,

    From your description, I noticed that the issue is not caused by Windows 7 system issues, but related to the source code. Since this forum is for Windows 7 technical questions, you may not be able to obtain useful information here. I suggest you discuss in our MSDN forum.

    Windows Native Development Forums


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    • Marked as answer by Arthur Xie Friday, August 20, 2010 9:51 AM
    Monday, August 16, 2010 3:31 AM
  • As unlikely as it seemed, I also saw this issue after adding an innocuous call to Clipboard.Clear. The entire VS2010 IDE would crash, and often other Office programs such as Outlook at the same time. I am also running Windows 7 64-bit. 

    This is pretty unacceptable robustness from MSFT. The host of issues in 64-bit are making it difficult to use for an extended period of time, and something as trivial as a clipboard operation crashing entire applications is.. gross.

    Wednesday, June 27, 2012 4:24 AM
  • This is on Windows 7 64 bit.  Create an empty Winforms app, add this line anywhere:

    Clipboard.Clear();

    Compile, execute, close. You can also download a small exe from here: ClipboardClear app.

    After you run the exe, when you right click on the desktop, the explorer memory gets corrupted, and the explorer will crash soon after. Opening and closing explorer windows two or three times triggers the crash.

    This is probably also what Firefox does in private mode after you close it, as some people have reported here.

    If you enable Full-page heap for explorer.exe, the moment of the right click is when the access violation happens. When the cliboard is empty, event viewer will also crash.

    Hey mestar, thank you so much for your diagnosis of this issue, the creation of your simple ClipboardClear app AND leaving it on your SkyDrive for so long.

    I have been struggling with the same issue for some time and thanks to you have been able to find the app (due to no fault of its own) causing the problem. It seems although MS acknowledged the issue to Mozilla all the way back in 2009 they have still not implemented a fix! Shame on them.

    Monday, September 24, 2012 2:37 PM
  • It is fixed now, I created a new WinForms app on Windows 8 targeting .Net 4.5, added Clipboard.Clear() to the Load() method for the formand right-clicked the desktop. Nothing out of the ordinary happens
    Monday, September 24, 2012 3:20 PM
  • That's great to hear, thanks, but it doesn't seem fixed on Windows 7, which will continue to be the corporate platform of choice and majority installed platform overall for at least the next few years.
    Monday, September 24, 2012 4:13 PM
  • ...or is it that apps targetting < .net 4 still have this problem (still very common), regardless of OS?

    Mike, any chance you could put your ClipboardClear app somewhere so I can test?

    Monday, September 24, 2012 4:42 PM
  • Actually, if I am reading things right  in WinDbg, mestar's app is using .net 4 here, so it looks like any fix is Windows 8 only.
    Monday, September 24, 2012 5:33 PM
  • OK, I tested this with .Net 2, 3 ,3.5, 4, and 4.5. All worked for me in Windows 8. I also tested in Windows Server 2008 R2, so this issue would likely be specific to Windows 7 (possibly with unpatched .Net?)

    https://skydrive.live.com/redir?resid=8F63F3F375A57B50!299

    Monday, September 24, 2012 7:03 PM
  • To be honest I am not sure I am running your version correctly, or even if it is possible with VisualStudio. Simply double-clicking the .exe in the bin folders does not seem to cause the problem here with any of the versions either and the clipboard does seem cleared. However, when the app I was having problems with clears the clipboard I do see the issue and when I run mestar's app. Either you are using a subtly different method or I am doing something wrong.

    Mike, could you try mestar's app on Windows 8? The link above still works.

    Monday, September 24, 2012 7:28 PM
  • I tested mestar's app in a Windows 8 VM, I couldn't reproduce a crash.
    Monday, September 24, 2012 7:38 PM
  • Hi Mestar,

    Thanks for this posting, this problem has been plaguing us for months! For us it looks like the problem only remains on Windows 7x64, but this is a very serious problem I can't believe MS has not fixed it yet. So what did you use to replace clipboard.clear()? Is there a different API call that you used to clear the clipboard or do you just not clear it?
    Monday, October 8, 2012 6:59 PM
  • You could always do something like Clipboard.SetText("");
    Monday, October 8, 2012 7:09 PM