- I’m the maintainer of the HanziStats plugin (plugin number 181243826)
- I recently upgraded my Anki Desktop version and notice that launching HanziStats now immediately crashes Anki. Sometimes the terminal says “Bus error” and sometimes says “Segmentation fault”. I see no other information in the terminal or in the
crash.logfile. I have no idea what I should do to “fix this”. The plugin had been running fine for years…
- I downloaded older versions of Anki and it seems this behavior begins with Anki 2.1.45 and later versions. No such crashes in Anki 2.1.44 or before.
- Problem does go away if I switch away from “Video driver: Software” to “Video Driver: OpenGL” (yes, this is the opposite from the usual advice to avoid crashes)
- I’m using Ubuntu 20.04 LTS . Yes, I’ve ran
sudo apt install libxcb-xinerama0. Yes, I’ve disable all other add-ons. Anki seems to run fine if I don’t try to launch the HanziStats plugin (click “Tools → Hanzi Stats”).
- Thanks for any help or information!
Hi, recently Anki has started encountering a segfault whenever I try to open the kanji stats window. This is almost certainly an issue with openSUSE’s Mesi-dri package, but unfortunately the Anki release binaries don’t have any debugging symbols so I can’t debug this any further than the following dmesg line:
[776164.804163] traps: Anki general protection fault ip:7f39446c56be sp:7fff618496e8 error:0 in swrast_dri.so[7f3944640000+10b7000]
Has anyone seen a similar issue, and if not how can I get usable debug symbols? With the switch to bazel it’s a bit difficult to figure out where the built binary is (and how to build a non-stripped binary). I opened a bug report in the openSUSE bug tracker but given there’s no debugging symbols in the Anki binary I probably won’t get much help.
As far as I can tell, everything else works in Anki – only the kanji stats window is causing the fault. This issue is happening in Anki 2.1.49, but 2.1.50-beta5 (qt6) has the same issue.
Can you reproduce it with a local Python installation?
I can reproduce it with that setup, but
./bin/pip install --upgrade --pre 'aqt[qt6]' ends up installing Anki 2.1.49, not the betas (I can see the betas in the upgrade output but
./bin/anki is Anki 2.1.49).
./bin/pip install --upgrade --pre 'aqt==2.1.50b4' doesn’t work either:
Collecting aqt==2.1.50b4 Using cached aqt-2.1.50b4-py3-none-any.whl (5.0 MB) Requirement already satisfied: flask in ./lib/python3.8/site-packages (from aqt==2.1.50b4) (2.0.3) ERROR: Could not find a version that satisfies the requirement anki==2.1.50b4 (from aqt) (from versions: 2.1.24+359b9f5c, 2.1.25, 2.1.26, 2.1.28, 2.1.29, 2.1.30, 2.1.31, 2.1.32, 2.1.33, 2.1.34, 2.1.35, 2.1.36, 2.1.37rc1, 2.1.37, 2.1.38b1, 2.1.38b2, 2.1.38b3, 2.1.38b4, 2.1.38, 2.1.39b1, 2.1.39b2, 2.1.39, 2.1.40, 2.1.41b1, 2.1.41b2, 2.1.41b3, 2.1.41b4, 2.1.41b5, 2.1.41b6, 2.1.41b7, 2.1.41, 2.1.42, 2.1.43b1, 2.1.43, 2.1.44b1, 2.1.44, 2.1.45a1, 2.1.45a2, 2.1.45a3, 2.1.45a4, 2.1.45b1, 2.1.45b2, 2.1.45b3, 2.1.45b4, 2.1.45b5, 2.1.45b6, 2.1.45rc1, 2.1.45rc2, 2.1.45, 2.1.46rc1, 2.1.46, 2.1.47rc1, 2.1.47rc2, 2.1.47, 2.1.48rc1, 2.1.48rc2, 2.1.48, 2.1.49) ERROR: No matching distribution found for anki==2.1.50b4
2.1.50 requires Python 3.9 or later.
The bug is likely QtWebEngine, or the way Anki is invoking it. You could try fiddling around with onKanjiStats() in the add-on - maybe removing the progress start/end lines, or changing .exec_() to .open() might help.
Edit: merged this into another post, as it appears HanziStats was originally based off KanjiStats, and they take the same approach to showing the webview.
I’ll play around with it to see what’s happening. It’s quite frustrating that I have a corefile but there’s no debugging symbols anywhere so the corefile is useless.
Switching to OpenGL rendering doesn’t solve the problem for me unfortunately.
From playing around with it, it seems that the core issue is
w.stdHtml (so it is related to QtWebEngine). If you remove that line, there’s no crash. Any HTML at all seems to be triggering the issue (even
rep = "<p>Hello world.</p>" will cause a crash). Switching to
w.setHtml doesn’t solve anything. Using
d.open doesn’t fix the crash either.
It’s very strange that this only happens with this particular pop-up.
I cannot reproduce with a local Python installation of Anki Beta. However the terminal output when launching suggests its using OpenGL rendering which works for me in Anki v2.1.49 and it seems the “Preferences” menu in Anki Version 2.1.50 (3564ece6) no longer gives me the option to turn the OpenGL rendering off:
GLImplementation: desktop Surface Type: OpenGL Surface Profile: CompatibilityProfile Surface Version: 4.6 Using Default SG Backend: yes Using Software Dynamic GL: no Using Angle: no
With Anki 2.1.49 with OpenGL disabled I observe what cyphar observed. Core issue seems to be
w.stdHtmland any HTML seems to cause the crash even if a basic “hello world”.
I also installed the Anki Plugin Kanji-stats (Anki plugin code 527366757 — unfortunately I’m not allowed to share links yet…) and oddly it doesn’t seem to trigger the Segfault even though the code is similar. However if I change HanziStats
onhanziStats()code to as closely match its
onKanjiStats()code I still get a Segfault in my plugin with OpenGL disabled in Anki 2.1.49…
Please try removing the progress start/finish calls, the saveGeom/restoreGeom calls, replacing .exec() with .open(), and calling stdHtml() after the open call instead of earlier. If that doesn’t work either, what happens if you use
mw.progress.timer(3000, lambda: w.stdHtml(rep), False) instead, and wait a few seconds?
Please try removing the progress start/finish calls, the saveGeom/restoreGeom calls, replacing .exec() with .open(), and calling stdHtml() after the open call instead of earlier.
Thanks! This fixes the problem for the Hanzi Stats add-on. An updated add-on has been uploaded to ankiweb.
Does the issue stay fixed if the save/restoreGeom() calls are restored? I will need to make similar changes to KanjiStats, but would like to preserve the position saving if it’s not the cause.
I was able to restore save/restoreGeom() support. The following seemed to work for me:
def onhanziStats(): rep = genhanziStats() d = QDialog(mw) l = QVBoxLayout() w = AnkiWebView() l.addWidget(w) d.setLayout(l) d.resize(500, 600) restoreGeom(d, "hanzistats") w.stdHtml(rep) d.exec() saveGeom(d, "hanzistats")
@cyphar could you please try replacing this file in the add-on, and confirm it fixes the problem for you?
That solves the issue for me, though
split_fields doesn’t exist in Anki 2.1.49 so I had to patch your fixed version slightly.
Thanks for confirming, I’ve just pushed an update targeted at 2.1.50+.