Skip to content

🐛 Bug Report: Pastebar locks clipboard for too long, causing CLIPBRD_E_CANT_OPEN in other apps #323

Open

Description

@moxuanyuan

🐛 Bug Report: PasteBar locks clipboard for too long, causing CLIPBRD_E_CANT_OPEN in other apps

Description:
I've encountered an issue where PasteBar seems to hold the Windows clipboard lock for an extended period when intercepting/reading new entries. This causes other applications that are actively trying to write to the clipboard to freeze, time out, or throw exceptions.

Impact & Evidence:
Specifically, when using "Flow Launcher" alongside PasteBar, any copy action from Flow Launcher hangs for several seconds and eventually throws a "Failed to copy" error.

Checking the error logs of Flow Launcher reveals a direct clipboard lock exception caused by PasteBar holding the lock too long:
System.Runtime.InteropServices.COMException (0x800401D0): OpenClipboard failed (0x800401D0 (CLIPBRD_E_CANT_OPEN))

Even though Flow Launcher has a built-in retry mechanism for writing to the clipboard, PasteBar holds the lock longer than the maximum retry duration, ultimately forcing the crash/error.

Steps to Reproduce:

  1. Keep PasteBar running in the background.
  2. Run Flow Launcher and trigger an action to copy text to the clipboard.
  3. Flow Launcher will hang significantly and eventually throw an OpenClipboard failed timeout error.
  4. Close/Exit PasteBar completely.
  5. Try copying from Flow Launcher again -> It works instantly without any issues.

Expected Behavior:
PasteBar should optimize its clipboard monitoring and reading logic to release the Windows clipboard lock much faster. It shouldn't block other applications from accessing the clipboard for such a long duration.

Environment:

  • Windows Version: Windows 11 Pro, Version 25H2 (OS Build 26200.7840)
  • PasteBar Version: 0.7.0
  • Flow Launcher Version: 2.1.1

Activity

  1. moxuanyuan commented on Mar 10, 2026

    @moxuanyuan
    Author

    Just to provide some additional technical context on what might be causing this under the hood:

    It seems the root cause is related to how the Windows clipboard global lock (Mutex) is being handled. The standard best practice for a clipboard manager is the "quick in, quick out" approach:

    1. Open the clipboard.
    2. Copy data to memory.
    3. Immediately close/release the clipboard lock.
    4. Process the data asynchronously in the background (e.g., UI updates, database saving, etc.).

    Right now, it appears PasteBar might be performing synchronous processing while still holding the OpenClipboard lock. Because the clipboard is a globally exclusive resource in Windows, holding this lock for too long starves other applications.

    For example, Flow Launcher actually has a built-in retry mechanism (RetryActionOnSTAThreadAsync) to handle temporary clipboard locks. However, PasteBar holds the lock longer than Flow Launcher's maximum retry duration, which ultimately forces the CLIPBRD_E_CANT_OPEN crash on their end.

    Decoupling the clipboard read action from the data processing action should resolve these conflicts and likely improve PasteBar's overall performance. Hope this helps point you in the right direction!

  2. kurdin commented on Mar 10, 2026

    @kurdin
    Contributor

    @moxuanyuan Thanks for the detailed report and technical context.

    I have 30K+ active Windows users and haven’t seen this reported before, but this does suggest there may be a real clipboard contention issue in PasteBar under specific conditions. Flow Launcher may be exposing the issue more clearly because it is sensitive to longer clipboard locks, but PasteBar still should not hold clipboard access long enough to cause retry exhaustion in another app.

    I’ll review the Windows clipboard monitoring path and look into this issue, but you free to create a PR if you can find anything that can fix the issue for you in source code.

    P.S I just tried Flow Launcher on my Windows 10 machine, it works fine with PasteBar I don't see any issues. Did you use any plugins for Clipboard ? Maybe best to use only one clipboard manager on your system as well, if you like Flow Launcher clipboard history you can disable PasteBar history capture and use only saved clips and native paste menu instead of full clipboard history / capture functionality.

  3. moxuanyuan commented on Mar 10, 2026

    @moxuanyuan
    Author

    @kurdin

    Thank you so much for the quick response and for personally testing this! I truly appreciate your openness to investigating this.

    I've performed some more thorough isolation testing on my end to provide more context:

    1. Environmental Limits: I am using Windows 11. Unfortunately, I don't have another machine with Windows 10 or a clean install to verify if this is specific to my environment, but I have tried to eliminate all possible variables.
    2. Minimal Setup: To be clear, I am only using PasteBar as my clipboard manager. During my tests:
      • I have completely disabled the built-in clipboard history in Flow Launcher.
      • I have also manually disabled Windows 11's native "Clipboard History" and "Sync" features in the system settings.
    3. Observation: Despite PasteBar being the only active clipboard listener, Flow Launcher still fails its core "copy to clipboard" function, consistently triggering the CLIPBRD_E_CANT_OPEN error in its logs.

    Thank you again for your time and for creating such a great tool. I'll stay tuned for any updates!

  4. kurdin commented on Mar 11, 2026

    @kurdin
    Contributor

    @moxuanyuan

    Flow Launcher still fails its core "copy to clipboard" function, consistently triggering the CLIPBRD_E_CANT_OPEN error in its logs.
    Can you please specify that did you type in Flow Launcher to use copy to clipboard functionality. I could not find any command that FL has for copy to clipboard. I could not replicate this error CLIPBRD_E_CANT_OPEN on my setup.

    I have completely disabled the built-in clipboard history in Flow Launcher.
    how would you do enable / disable this in FL ?

    here is what I see with standard FL on copy to clipboard
    Image

    the only clipboard functionality I found is using plugins
    Image

    Can you see if you using any clipboard plugins, if so, try to disable it.

    Thank you for your help.

  5. moxuanyuan commented on Mar 27, 2026

    @moxuanyuan
    Author

    clipboard plugins

    I am not using any clipboard plugins in Flow Launcher.

    Yesterday I was on another PC, completely reinstalled windows 11 25H2, only installed Flow Launcher and Pastebar, and the problem still exists.

    Also, I found that Pastebar is also in conflict with ContextMenuManager.

    Image

    As pictured above, when I click on "Copy GUID", sometimes the first or second time it pops up an error prompt like the following. When I close the paste bar, everything works fine.

    Image
    
    有关调用实时(JIT)调试而不是此对话框的详细信息,
    请参见此消息的结尾。
    
    ************** 异常文本 **************
    System.Runtime.InteropServices.ExternalException (0x800401D0): 所请求的剪贴板操作失败。
       在 System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
       在 System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)
       在 System.Windows.Forms.Clipboard.SetText(String text, TextDataFormat format)
       在 ContextMenuManager.Controls.Interfaces.HandleGuidMenuItem.CopyGuid()
       在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
       在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
       在 System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** 已加载的程序集 **************
    mscorlib
        程序集版本:4.0.0.0
        Win32 版本:4.8.9221.0 built by: NET481REL1LAST_25H2
        基本代码:file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
    ----------------------------------------
    ContextMenuManager
        程序集版本:3.3.3.1
        Win32 版本:3.3.3.1
        基本代码:file:///D:/Scoop/apps/BluePointLilac.ContextMenuManager/current/ContextMenuManager.NET.4.0.exe
    ----------------------------------------
    System.Windows.Forms
        程序集版本:4.0.0.0
        Win32 版本:4.8.9221.0 built by: NET481REL1LAST_25H2
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        程序集版本:4.0.0.0
        Win32 版本:4.8.9321.0 built by: NET481REL1LAST_25H2_B
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        程序集版本:4.0.0.0
        Win32 版本:4.8.9221.0 built by: NET481REL1LAST_25H2
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Core
        程序集版本:4.0.0.0
        Win32 版本:4.8.9319.0 built by: NET481REL1LAST_25H2_B
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Xml
        程序集版本:4.0.0.0
        Win32 版本:4.8.9221.0 built by: NET481REL1LAST_25H2
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    PresentationFramework
        程序集版本:4.0.0.0
        Win32 版本:4.8.9319.0
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll
    ----------------------------------------
    WindowsBase
        程序集版本:4.0.0.0
        Win32 版本:4.8.9319.0 built by: NET481REL1LAST_25H2_B
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll
    ----------------------------------------
    PresentationCore
        程序集版本:4.0.0.0
        Win32 版本:4.8.9319.0 built by: NET481REL1LAST_25H2_B
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll
    ----------------------------------------
    System.Configuration
        程序集版本:4.0.0.0
        Win32 版本:4.8.9221.0 built by: NET481REL1LAST_25H2
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    mscorlib.resources
        程序集版本:4.0.0.0
        Win32 版本:4.8.9032.0 built by: NET481REL1
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll
    ----------------------------------------
    System.Drawing.resources
        程序集版本:4.0.0.0
        Win32 版本:4.8.9032.0 built by: NET481REL1
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing.resources/v4.0_4.0.0.0_zh-Hans_b03f5f7f11d50a3a/System.Drawing.resources.dll
    ----------------------------------------
    System.Windows.Forms.resources
        程序集版本:4.0.0.0
        Win32 版本:4.8.9032.0 built by: NET481REL1
        基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll
    ----------------------------------------
    
    ************** JIT 调试 **************
    要启用实时(JIT)调试,
    该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
    jitDebugging 值。
    编译应用程序时还必须启用
    调试。
    
    例如:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    启用 JIT 调试后,任何未经处理的异常
    都将被发送到在此计算机上注册的 JIT 调试程序,
    而不是由此对话框处理。
    
    
  6. kurdin commented on Apr 4, 2026

    @kurdin
    Contributor

    @moxuanyuan could you provide step by step instruction how to copy with Flow Launcher ? I use it daily and do not see any issues with PasteBar, but I do not use Flow Launcher to copy anything, I do not know how to do it. Let me know.

  7. randomhero0 commented on Jun 25, 2026

    @randomhero0

    @kurdin you can trigger the clipboard (and thus the error with FL and Pastebar) with the calculator plugin. type any number or calculation in flow launcher, press enter and the error will appear.

    Image

    Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions