Precompiling Mousetrap fails on Ubuntu with NVidia driver

I have the following issue:

julia> using Mousetrap
[ Info: Precompiling Mousetrap [5deeb4b9-6e04-4da7-8b7f-c77fb1eae65e]

[25147] signal (11.1): Segmentation fault
in expression starting at /home/ufechner/.julia/packages/Mousetrap/k0X9u/src/Mousetrap.jl:39
gdk_x11_surface_get_xid at /home/ufechner/.julia/artifacts/5498f875c31a1b3422ce1b64ef770407109eff30/lib/libgtk-4.so (unknown line)

I already reported this as bug, On Ubuntu 22.04 with Nvidia driver moustrap 0.2 crashes · Issue #25 · Clemapfel/Mousetrap.jl · GitHub
but perhaps here somebody has an idea how to debug this kind of issues?

I created a virtual machine with Ubuntu 22.04, and there it works fine…

It also works with the nouveau graphics driver, but not with the official nvidea graphics drivers, which is strange…

Does anybody know how to run Julia under GDB to get a proper stack trace?

https://docs.julialang.org/en/v1/devdocs/backtraces/

Is it needed to create a debug build of Julia to debug the crash in this library?

Yes, a make debug is needed if you want good stacktraces.