spacedriveapp / spacedrive

Spacedrive is an open source cross-platform file explorer, powered by a virtual distributed filesystem written in Rust.
https://spacedrive.com
GNU Affero General Public License v3.0
29.33k stars 835 forks source link

Segfault on Nvidia with X11 #2541

Closed username227 closed 2 weeks ago

username227 commented 2 weeks ago

Describe the bug

Program segfaults when opening with x11. Issue is related to this rust problem: https://internals.rust-lang.org/t/global-symbols-from-statically-linked-system-libraries/19954 Problem is present when running on nvidia card, and is not an issue with your program per se (see easy proposed fix below).

Reproduction

Start program with nvidia graphics on x11

Expected behavior

program should open normally.

Platform and versions

Arch / Cinnamon / Nvidia.

Stack trace

backtrace:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffda8006c0 (LWP 110506)]
[New Thread 0x7fffda4006c0 (LWP 110507)]
[New Thread 0x7fffda0006c0 (LWP 110508)]
[New Thread 0x7fffd9c006c0 (LWP 110509)]
[New Thread 0x7fffd98006c0 (LWP 110510)]
[New Thread 0x7fffd94006c0 (LWP 110511)]
[New Thread 0x7fffd90006c0 (LWP 110512)]
[New Thread 0x7fffd8c006c0 (LWP 110513)]
[New Thread 0x7fffd88006c0 (LWP 110514)]
[New Thread 0x7fffd84006c0 (LWP 110515)]
[New Thread 0x7fffd3e006c0 (LWP 110516)]
[New Thread 0x7fffd3a006c0 (LWP 110517)]
[New Thread 0x7fffd36006c0 (LWP 110518)]
[New Thread 0x7fffd2c006c0 (LWP 110519)]
[New Thread 0x7fffd22006c0 (LWP 110520)]
[New Thread 0x7fffd14006c0 (LWP 110521)]
[New Thread 0x7fffd10006c0 (LWP 110522)]
[New Thread 0x7fffc5e006c0 (LWP 110523)]
[New Thread 0x7fffc54006c0 (LWP 110524)]
[Detaching after vfork from child process 110525]

Thread 1 "spacedrive" received signal SIGSEGV, Segmentation fault.
0x00007fffedc71434 in pthread_mutex_lock () from /usr/lib/libc.so.6

Additional context

The program will start normally with the following environment variable: WEBKIT_DISABLE_DMABUF_RENDERER=1 I have fixed the spacedrive-bin package on the AUR. You should consider adding this to the desktop file Exec to avoid issues until rust fixes the problem.

HeavenVolkoff commented 2 weeks ago

Hey, thanks for reporting this issue. Can you try building this PR: #2542 and running without explicitly setting WEBKIT_DISABLE_DMABUF_RENDERER to see if it works

username227 commented 2 weeks ago

hmmm....it's possible I did something wrong during compiling, but this version doesn't seem to work at all, both with and without the variable I get a segfault...

username227 commented 2 weeks ago

this branch DOES still work on Wayland. on x11 gives segfault (similar backtrace) now both with and without the environment variable.

username227 commented 2 weeks ago

I can also confirm that the executable from this branch also DOES work if the nvidia card is not used - on integrated AMD GPU with X11. So whatever's going on is still definitely related to this issue.

HeavenVolkoff commented 2 weeks ago

Updated the PR, @username227 can you try again?

username227 commented 2 weeks ago

Appears to start properly now. Great work.

HeavenVolkoff commented 2 weeks ago

@username227 I updated the PR again. I think that now that we are not statically compiling dbus into the app, it should run fine on Nvidia, even without the WEBKIT_DISABLE_DMABUF_RENDERER env var being set internally, as I was previously doing. Could you try it again to make sure it continues to work properly?

username227 commented 2 weeks ago

OK; with the environment variable, it works normally. without the environment variable, it no longer segfaults, but graphics do not come up properly either. I get the following error:

AcceleratedSurfaceDMABuf was unable to construct a complete framebuffer

which seems to repeat until I close the window.

HeavenVolkoff commented 2 weeks ago

AcceleratedSurfaceDMABuf was unable to construct a complete framebuffer

Hun, seems like this is a known issue: https://github.com/tauri-apps/tauri/issues/9304

Most likely, something is broken in webkit2gtk. I will put back the code to inject WEBKIT_DISABLE_DMABUF_RENDERER when running under Nvidia on Linux, as that seems to be the best alternative for now.

@username227 thanks for the help with the tests.

username227 commented 2 weeks ago

makes sense. I'm not convinced that it's really the fault of webkit2gtk. I think it's a combination of the interaction of rust, tauri, and webkit2gtk. good thing they have the workaround is all I can say.

HeavenVolkoff commented 2 weeks ago

Hey, @username227 I updated the logic for detecting nvidia cards (replaced gl/glfw with wgpu), could you give it a test to check if it is still working properly...

username227 commented 2 weeks ago

@HeavenVolkoff Yes, still works.