Bug 270778 - games/anki: causes python to segfault with nvidia driver
Summary: games/anki: causes python to segfault with nvidia driver
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Kai Knoblich
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2023-04-12 03:19 UTC by bitbucket63-it
Modified: 2023-05-02 06:55 UTC (History)
1 user (show)

See Also:
kai: maintainer-feedback+


Attachments
anki-fix-runtime-issues-with-nvidia-drivers.patch (1.07 KB, patch)
2023-04-15 21:28 UTC, Kai Knoblich
kai: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bitbucket63-it 2023-04-12 03:19:10 UTC
Since updating last week I have not been able to get games/anki to run. It causes a segfault in python3.9. I ran it through lldb and got the following:

me@mymachine ~ 0> lldb python3.9 `which anki`
(lldb) target create "python3.9"
Current executable set to 'python3.9' (x86_64).
(lldb) settings set -- target.run-args  "/usr/local/bin/anki"
(lldb) r
Process 7431 launched: '/usr/local/bin/python3.9' (x86_64)
Running with temporary Qt5 compatibility shims.
Run with DISABLE_QT5_COMPAT=1 to confirm compatibility with Qt6.
Preparing to run...
Qt warning: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-jtm' 
Process 7431 stopped
* thread #1, name = 'python3.9', stop reason = signal SIGSEGV: invalid address (fault address: 0xb0)
    frame #0: 0x000000081483aa74 libGL-NVIDIA.so.1`___lldb_unnamed_symbol3487 + 212
libGL-NVIDIA.so.1`___lldb_unnamed_symbol3487:
->  0x81483aa74 <+212>: movl   0xb0(%r13), %esi
    0x81483aa7b <+219>: movq   %rbp, %rdi
    0x81483aa7e <+222>: callq  0x81480d690               ; ___lldb_unnamed_symbol2654
    0x81483aa83 <+227>: testq  %rax, %rax
(lldb)


FreeBSD 12.4-RELEASE-p2 FreeBSD 12.4-RELEASE-p2 releng/12.4-n235816-149768b65d61 JAMESTOWN_AMDX6  amd64

anki is built with qt6

The Nvidia driver version I'm using is x11/nvidia-driver-340 because it's an old graphics card not supported by the latest drivers.

I'm uncertain if this is an anki problem, an nvidia problem, or some other problem.

All ports were rebuilt and reinstalled 4/9/23 using poudriere and there were no errors I found in the relevant logs.
Comment 1 Kai Knoblich freebsd_committer freebsd_triage 2023-04-14 08:54:08 UTC
(In reply to bitbucket63-it from comment #0)

Thanks for your info. I can confirm it myself on a system that runs FreeBSD 12.4-RELEASE amd64 and that uses a nvidia-driver-390.

It seems to affect only systems that use a nvidia driver, because Anki runs without problems on FreeBSD 12.4-RELEASE adm64 with an Intel HD Graphics 500 driver..

Interestingly, deskutils/calibre, which uses also PyQt6, seems to run without problems on FreeBSD 12.4-RELEASE with nvidia drivers. If you're using deskutils/calibre by any chance, can you confirm it too? 


I have not yet had enough time to investigate this further. So far I can say the following:

- Affects only systems with nvidia drivers.
- It seems to be caused by Anki itself in conjunction with PyQt6, because deskutils/calibre, that uses PyQt6 as well, runs in the same environment (= FreeBSD 12.4-RELEASE with nvidia driver) without problems.
- As soon as line #283 in /usr/local/share/anki/aqt/__init__.py is executed by Python, it comes to the core dump.

I'll keep you posted once I've some more info.
Comment 2 bitbucket63-it 2023-04-14 17:00:42 UTC
I installed deskutils/calibre and it ran. I tried searching, adding a pdf to the library, and reading the manual. It kept throwing warnings like

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-jtm'
No suitable graphics backend found

but it never crashed and as far as I could tell was functioning properly.

I have not updated my ports tree so it's from the same version as before.
Comment 3 Kai Knoblich freebsd_committer freebsd_triage 2023-04-15 21:28:45 UTC
Created attachment 241518 [details]
anki-fix-runtime-issues-with-nvidia-drivers.patch

(In reply to bitbucket63-it from comment #2)

Thanks for your feedback and.  Attached is a patch that should fix the issues you reported. Can you please give it a try?

If everything works as expected I'll commit that patch in next few days.
Comment 4 bitbucket63-it 2023-04-16 19:56:23 UTC
(In reply to Kai Knoblich from comment #3)
I applied the patch and the problem is solved.

Thank you so much.
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-05-02 06:37:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=bdcfffd8573e09ef4c838b3dd1444fa15e508c4e

commit bdcfffd8573e09ef4c838b3dd1444fa15e508c4e
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2023-05-02 06:34:24 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2023-05-02 06:34:24 +0000

    games/anki: Fix crashes with nVidia drivers

    * Prevent Anki from explicitly loading "libGL.so.1", which leads to
      segfaults in environments that have nVidia drivers in use.

    * Bump PORTREVISION due package change.

    PR:             270778
    Reported by:    bitbucket63-it@yahoo.com
    MFH:            2023Q2

 games/anki/Makefile                                 |  2 +-
 games/anki/files/patch-qt_aqt_____init____.py (new) | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-05-02 06:43:14 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8c86204b79a203a15bd18017e306bc6d08a0305a

commit 8c86204b79a203a15bd18017e306bc6d08a0305a
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2023-05-02 06:34:24 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2023-05-02 06:41:49 +0000

    games/anki: Fix crashes with nVidia drivers

    * Prevent Anki from explicitly loading "libGL.so.1", which leads to
      segfaults in environments that have nVidia drivers in use.

    * Bump PORTREVISION due package change.

    PR:             270778
    Reported by:    bitbucket63-it@yahoo.com
    MFH:            2023Q2

    (cherry picked from commit bdcfffd8573e09ef4c838b3dd1444fa15e508c4e)

 games/anki/Makefile                                 |  2 +-
 games/anki/files/patch-qt_aqt_____init____.py (new) | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Comment 7 Kai Knoblich freebsd_committer freebsd_triage 2023-05-02 06:55:48 UTC
(In reply to bitbucket63-it from comment #4)

That's nice to hear that your reported issue is fixed. I committed the patch to the main branch and MFH'd it to the 2023Q2 branch.

Once again thank you for the report and your feedback!