Anki Crash on Windows

For some reason, AnkiMCP causes repeated Anki crashes on Windows.

I cannot attach the crash log here, so I asked AI to sum up the crash log, the crash lists only the AnkiMCP addon.

↓↓↓ Here’s what AI had to say: ↓↓↓

Based on the crash log, the crash was caused by a conflict between Anki’s main Qt UI loop and a background thread running an add-on.


1. The Culprit Add-on

Looking at the stack trace:

Thread 0x000013b4 / 0x0000502c:
  File "C:\Users\USER\AppData\Roaming\Anki2\addons21\124672614\mcp_server.py", line 626 in _run
  • Add-on code: 124672614
  • Add-on name: Anki MCP Server (ankimcp.ai)

2. Root Cause Analysis

  1. Unsafe Background Threading / Cross-Thread Access:
    The Anki MCP add-on spawns a background thread running an asyncio event loop/server (mcp_server.py:626). Anki’s backend, SQLite database, and PyQt GUI are strictly not thread-safe. If an add-on makes calls to Anki objects or UI components from a secondary thread without synchronizing through Anki’s main thread (e.g., via run_on_main()), memory corruption occurs.
  2. The Crash Sequence:
    • Windows fatal exception: code 0xe0000002: This repeatedly triggered first—representing an unhandled application-level C++ or COM/runtime software exception (often from Qt or embedded web engines).

    • Windows fatal exception: access violation: Shortly after, Anki’s main GUI thread (responsible for the Qt event loop) crashed with a segmentation fault/access violation while handling UI events:

      Thread 0x00006924:
        File "aqt\__init__.py", line 475 in eventFilter
      

Hi, sorry about the crashes — let’s figure this out.

One thing up front: the crash report lists every running part of Anki, and AnkiMCP always shows up there simply because it’s running in the background. So the report alone doesn’t tell us yet whether AnkiMCP is actually the cause. The crash itself happened in Anki’s own window code, which is why I’d like a bit more detail to narrow it down.

Could you help with a few quick things?

  1. Paste the full crash log here. You can’t attach files, but pasting the text works fine. Click the </> button in the editor toolbar first (it keeps the formatting), then paste the whole thing. Long is fine.

  2. Versions. In Anki, go to Tools → AnkiMCP Server Settings…, click Copy diagnostics, and paste the result here. That gives me your Anki and AnkiMCP versions in one go.

  3. What were you doing when it crashed? For example: reviewing cards, had an AI tool (Claude, ChatGPT, etc.) connected and working with your deck, opening the browser window, just moving the mouse around? And does it crash at random, or at the same moment each time?

  4. Which connection do you use? Just the normal local connection, or the “Connect Tunnel” button in the same settings window?

  5. Does it still crash with only AnkiMCP enabled? Hold Shift while starting Anki — this starts it with all add-ons off. Then go to Tools → Add-ons, enable only AnkiMCP, restart Anki, and use it normally for a bit. If it still crashes, we know it’s us. If not, another add-on is involved.

That’s all. Once I have the log and versions I can look at what’s actually going on.

Here’s the requested data:

  1. No to make the scrollbar on this thread tiny, I pasted the log in Pastebin instead. Find it at : Crash Log - Pastebin.com
============================================================
AnkiMCP Server diagnostics
============================================================
Add-on version : 0.40.0
Python         : 3.13.15
Platform       : Windows-11-10.0.26300-SP0
Machine        : AMD64
Anki           : 26.09.2
Qt             : 6.11.2

Transports:
  HTTP   : enabled (running)
  Tunnel : not connected

Loaded module provenance (sys.modules; not force-imported):
  pydantic          : 2.13.5  (C:\Users\REDACTED\AppData\Roaming\Anki2\addons21\124672614\vendor\shared\pydantic\__init__.py)
  pydantic_core     : 2.46.5  (C:\Users\REDACTED\AppData\Roaming\Anki2\ankimcp\124672614\cache\pydantic_core_pkg\pydantic_core\__init__.py)
  typing_extensions : 4.16.0  (C:\Users\REDACTED\AppData\Local\Programs\Anki\app_packages\typing_extensions.pyc)
  mcp               : 1.30.0  (C:\Users\REDACTED\AppData\Roaming\Anki2\addons21\124672614\vendor\shared\mcp\__init__.py)
  starlette         : 1.7.0  (C:\Users\REDACTED\AppData\Roaming\Anki2\addons21\124672614\vendor\shared\starlette\__init__.py)
  uvicorn           : 0.54.0  (C:\Users\REDACTED\AppData\Roaming\Anki2\addons21\124672614\vendor\shared\uvicorn\__init__.py)
  google.protobuf   : 6.33.5  (C:\Users\REDACTED\AppData\Local\Programs\Anki\app_packages\google\protobuf\__init__.pyc)
  certifi           : 2025.06.15  (C:\Users\REDACTED\AppData\Local\Programs\Anki\app_packages\certifi\__init__.pyc)
  urllib3           : 2.7.0  (C:\Users\REDACTED\AppData\Local\Programs\Anki\app_packages\urllib3\__init__.pyc)
============================================================
  1. Usually when reviewing, but Anki did crash in other places.
  2. Normal local connection
  3. Unfortunately, I cannot reproduce the bug as it doesn’t happen eveyrtime. I will disable AnkiMCP for a few days and see, if it crashed once, then I’ll let you know it’s not AnkiMCP that’s causing the crash.

Thanks, that log is exactly what I needed. I went through all of it, and here’s what it shows.

The log covers four separate Anki sessions, not one. You can tell by the thread numbers changing. In the last session, which has 48 of those 0xe0000002 lines (more than any other), AnkiMCP wasn’t running at all. So those repeated lines have nothing to do with AnkiMCP. They’re a known quirk of Python’s crash reporter on Windows: it prints a scary “fatal exception” line for errors that Windows or Qt then handle internally, so Anki just carries on. That’s why they repeat without Anki closing.

The one real crash happened in the third session. At that exact moment AnkiMCP’s background part was sitting idle, waiting for a connection, with nothing in flight. The crash itself was inside Anki’s own window-handling code, the part that updates the mouse cursor when you hover over buttons. I can’t rule us out with 100% certainty from this alone, but nothing in the log points at AnkiMCP.

Something worth trying regardless. Your Anki (26.09.2) uses a new graphics layer (Qt 6.11), and the Anki forums have several reports of random crashes and blank windows on Windows with that version, with add-ons disabled too. The fix that worked for those people: in Anki go to Tools → Preferences → Appearance, change Video driver to Software, and restart Anki. If the crashes stop, that was it.

Your plan is the right one. Keep AnkiMCP off for a few days. If Anki still crashes, we’re off the hook and the video driver / Anki version is the place to look. If it doesn’t crash at all, turn AnkiMCP back on and tell me; I’ll then give you one setting to switch on that writes a small log file so we can line up what AnkiMCP was doing at the moment of the next crash.

One more useful thing: since 26.09, Anki writes a crash.log file into its data folder (same folder as addons21). If it crashes again, that file has more detail than the console dump.

1 Like

Confirmed! Crash has nothing to do with any addon apparently. Just crashed and the logs don’t mention any addon. So it’s entirely an Anki problem.

I will try the Video driver option. Thanks for your time on this matter.

Glad we got to the bottom of it, and thanks for taking the time to test properly. That’s genuinely helpful.

If the video driver switch doesn’t settle it, the Anki forums (forums.ankiweb.net) are the right place to report it, and that crash.log file from the Anki folder is what they’ll want to see.

Good luck with the studying!

1 Like