Skip to content

[SystrayMonitor] Fatal crash: access violation in validate_icon_data / RPC_E_WRONG_THREAD (0x8001010e) on WM_COPYDATA #906

@AntonSerg

Description

@AntonSerg

Windows version

Windows 11

Windows OS build

Windows 11 25H2 2600.8037

YASB version installed

2.0.0

Describe the bug

Bug description

YASB crashes intermittently with two distinct fatal exceptions, both originating from the SystrayMonitor thread.


Crash 1 — Access violation in validate_icon_data

Date: 2026-05-10
Error: Windows fatal exception: access violation
Thread: SystrayMonitor

The crash occurs while processing a WM_COPYDATA message from a third-party tray application. The monitor attempts to validate icon data inside validate_icon_data (utils.py:229), but the pointer or buffer received in COPYDATASTRUCT is invalid or already freed, resulting in an access violation.

Stack trace (current thread):

systray/utils.py, line 229 in validate_icon_data
systray_monitor.py, line 158 in handle_copy_data
systray_monitor.py, line 142 in _window_proc
systray/utils.py, line 145 in start_message_loop
systray_monitor.py, line 99 in run
yasb/systray.py, line 65 in run

Crash 2 — COM thread violation (RPC_E_WRONG_THREAD)

Date: 2026-05-09
Error: Windows fatal exception: code 0x8001010e (RPC_E_WRONG_THREAD)
Thread: MainThread via qasync timerEvent

A COM object (likely Windows Notifications or systray-related) was created on one thread but accessed from another, violating COM apartment threading rules.

Stack trace (current thread):

asyncio/events.py, line 94 in _run
qasync/__init__.py, line 307 in timerEvent
qasync/__init__.py, line 404 in run_forever
main.py, line 98 in main

Expected behavior

SystrayMonitor should safely handle malformed or unexpected WM_COPYDATA payloads without crashing the entire process. Invalid icon data should be silently skipped or logged.

Suggested fix

  • Wrap the body of validate_icon_data in a try/except (or structured exception handler) to catch invalid memory access.
  • Validate cbData size before dereferencing the data pointer in handle_copy_data.
  • Ensure COM objects used in WindowsNotificationEventListener are initialized and accessed on the correct STA thread.

Relevant log output

1:
Windows fatal exception: code 0x8001010e

Thread 0x00005864 [asyncio_0] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 373 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 670 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 73 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 86 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 119 in _worker
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x000053fc [SystrayMonitor] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\utils.py", line 145 in start_message_loop
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\systray_monitor.py", line 99 in run
  File "D:\a\yasb\yasb\src\core\widgets\yasb\systray.py", line 65 in run

Thread 0x00005b0c [Thread-8] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 369 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\queue.py", line 199 in get
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 379 in dispatch_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 213 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00004620 [Thread-10] (most recent call first):
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\winapi.py", line 326 in read_directory_changes
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\winapi.py", line 380 in read_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\read_directory_changes.py", line 67 in _read_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\read_directory_changes.py", line 70 in queue_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 158 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00005b08 [WindowsNotificationEventListener] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\windows_events.py", line 775 in _poll
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\windows_events.py", line 446 in select
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 2019 in _run_once
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 677 in run_forever
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 706 in run_until_complete
  File "D:\a\yasb\yasb\src\core\widgets\services\notifications\windows_notification.py", line 101 in run

Thread 0x000054b0 [KomorebiEventListener] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 373 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 670 in wait
  File "D:\a\yasb\yasb\src\core\widgets\services\komorebi\event_listener.py", line 139 in _wait_until_komorebi_online
  File "D:\a\yasb\yasb\src\core\widgets\services\komorebi\event_listener.py", line 69 in run

Thread 0x000055d8 [WiFiWorker] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\wifi\wifi_managers.py", line 150 in run

Thread 0x00005584 [Thread-3 (process_audio)] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\yasb\cava.py", line 586 in process_audio
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00004fd8 [CpuWorker] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\cpu\cpu_api.py", line 318 in run

Thread 0x00001714 [_EventWorker] (most recent call first):
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 147 in _poll
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 72 in select
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 199 in run

Thread 0x000058a4 [LogPipeServer] (most recent call first):
  File "D:\a\yasb\yasb\src\core\utils\win32\bindings\kernel32.py", line 288 in ConnectNamedPipe
  File "D:\a\yasb\yasb\src\core\utils\cli_server.py", line 138 in _run_server
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00005720 [CLIPipeServer] (most recent call first):
  File "D:\a\yasb\yasb\src\core\utils\win32\bindings\kernel32.py", line 288 in ConnectNamedPipe
  File "D:\a\yasb\yasb\src\core\utils\cli_server.py", line 235 in _run_server
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Current thread 0x000057f0 (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\events.py", line 94 in _run
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\__init__.py", line 307 in timerEvent
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\__init__.py", line 404 in run_forever
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\__init__.py", line 428 in run_until_complete
  File "main.py", line 98 in main
  File "main.py", line 188 in <module>
  File "D:\a\yasb\yasb\venv\Lib\site-packages\freeze_core\initscripts\console.py", line 27 in run
  File "D:\a\yasb\yasb\venv\Lib\site-packages\freeze_core\initscripts\__startup__.py", line 137 in run

Current thread's C stack trace (most recent call first):
  <cannot get C stack on this system>

2:
Windows fatal exception: access violation

Thread 0x00005864 [asyncio_0] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 373 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 670 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 73 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 86 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\concurrent\futures\thread.py", line 119 in _worker
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Current thread 0x000053fc [SystrayMonitor] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\utils.py", line 229 in validate_icon_data
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\systray_monitor.py", line 158 in handle_copy_data
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\systray_monitor.py", line 142 in _window_proc
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\utils.py", line 145 in start_message_loop
  File "D:\a\yasb\yasb\src\core\widgets\services\systray\systray_monitor.py", line 99 in run
  File "D:\a\yasb\yasb\src\core\widgets\yasb\systray.py", line 65 in run

Thread 0x00005b0c [Thread-8] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 369 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\queue.py", line 199 in get
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 379 in dispatch_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 213 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00004620 [Thread-10] (most recent call first):
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\winapi.py", line 326 in read_directory_changes
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\winapi.py", line 380 in read_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\read_directory_changes.py", line 67 in _read_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\read_directory_changes.py", line 70 in queue_events
  File "D:\a\yasb\yasb\venv\Lib\site-packages\watchdog\observers\api.py", line 158 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00005b08 [WindowsNotificationEventListener] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\windows_events.py", line 775 in _poll
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\windows_events.py", line 446 in select
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 2019 in _run_once
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 677 in run_forever
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\asyncio\base_events.py", line 706 in run_until_complete
  File "D:\a\yasb\yasb\src\core\widgets\services\notifications\windows_notification.py", line 101 in run

Thread 0x000054b0 [KomorebiEventListener] (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 373 in wait
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 670 in wait
  File "D:\a\yasb\yasb\src\core\widgets\services\komorebi\event_listener.py", line 139 in _wait_until_komorebi_online
  File "D:\a\yasb\yasb\src\core\widgets\services\komorebi\event_listener.py", line 69 in run

Thread 0x000055d8 [WiFiWorker] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\wifi\wifi_managers.py", line 150 in run

Thread 0x00005584 [Thread-3 (process_audio)] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\yasb\cava.py", line 586 in process_audio
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00004fd8 [CpuWorker] (most recent call first):
  File "D:\a\yasb\yasb\src\core\widgets\services\cpu\cpu_api.py", line 318 in run

Thread 0x00001714 [_EventWorker] (most recent call first):
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 147 in _poll
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 72 in select
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\_windows.py", line 199 in run

Thread 0x000058a4 [LogPipeServer] (most recent call first):
  File "D:\a\yasb\yasb\src\core\utils\win32\bindings\kernel32.py", line 288 in ConnectNamedPipe
  File "D:\a\yasb\yasb\src\core\utils\cli_server.py", line 138 in _run_server
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x00005720 [CLIPipeServer] (most recent call first):
  File "D:\a\yasb\yasb\src\core\utils\win32\bindings\kernel32.py", line 288 in ConnectNamedPipe
  File "D:\a\yasb\yasb\src\core\utils\cli_server.py", line 235 in _run_server
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1024 in run
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1082 in _bootstrap_inner
  File "C:\hostedtoolcache\windows\Python\3.14.4\x64\Lib\threading.py", line 1044 in _bootstrap

Thread 0x000057f0 (most recent call first):
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\__init__.py", line 404 in run_forever
  File "D:\a\yasb\yasb\venv\Lib\site-packages\qasync\__init__.py", line 428 in run_until_complete
  File "main.py", line 98 in main
  File "main.py", line 188 in <module>
  File "D:\a\yasb\yasb\venv\Lib\site-packages\freeze_core\initscripts\console.py", line 27 in run
  File "D:\a\yasb\yasb\venv\Lib\site-packages\freeze_core\initscripts\__startup__.py", line 137 in run

Current thread's C stack trace (most recent call first):
  <cannot get C stack on this system>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions