fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
8.43k stars 350 forks source link

Segmentation fault #83

Closed AdisonCavani closed 2 years ago

AdisonCavani commented 2 years ago

I have installed fastfetch from AUR on WSL2 (ArchLinux) and I'm getting "segmentation fault". Image

LinusDierheimer commented 2 years ago

Its hard to tell where the problem is just from the image, as fastfetch is multi threaded and any of those threads may segfault. Use fastfetch --multithreading false and tell me where it does stop now.

AdisonCavani commented 2 years ago

error: XDG_RUNTIME_DIR not set in the environment. [1] 4258 segmentation fault fastfetch --multithreading false

LinusDierheimer commented 2 years ago

This is more complicated as it looks, as i never use XDG_RUNTIME_DIR. The question where it stops remains.

LinusDierheimer commented 2 years ago

This seems to be something specific with your setup, XDG_RUNTIME_DIR= fastfetch executes totally normal on my system, as it should. I don't have Windows installed so i can't test in WSL2. Without more information from you i can't do anything.

AdisonCavani commented 2 years ago

error This is how it looks on my WSL2

AdisonCavani commented 2 years ago

After adding:

export XDG_RUNTIME_DIR=/some/directory/you/specify 
export RUNLEVEL=3

to .zshrc, XDG_RUNTIME_DIR not set in the environment is no longer visible, but I'm getting another error:

error2

LinusDierheimer commented 2 years ago

Resolution seems to be the problem. Fastfetch first tries to use on of the libraries in specified order:

Most probably you have one of the X11 libraries installed as a dependency, but no X Server running. This isn't a problem on linux, as i have implemented and tested this scenario, but maybe WSL2 behaves different. Can you look which of those libraries are present?

If resolution detection fails for all three, fastfetch falls back to scanning /sys/class/drm/*/modes itself. But this surely doesn't need XDG_RUNTIME_DIR, so the error is most probably in some X Configuration.

AdisonCavani commented 2 years ago

libs

I've got this three libraries installed, but I don't have got /sys/class/drm/*modes:

sys

LinusDierheimer commented 2 years ago

I assume you are compiling for yourself, so this shouldn't be much of a problem:

Go to the bottom of src/modules/resolution.c. You'll find the following function there:

void ffPrintResolution(FFinstance* instance)
{
    if(
        printResolutionWaylandBackend(instance) ||
        printResolutionXrandrBackend(instance) ||
        printResolutionX11Backend(instance)
    ) return;

    printResolutionDRMBackend(instance);
}

Each printResolution* line calls a resolution implementation. Use comments (start the line with //) to disable them one by one. This way you can find out which implementation fails. Sorry for the extra work.

AdisonCavani commented 2 years ago

After commenting out first printResolution* should I uncomment first, and comment second or should I comment first, comment second and comment third at the end?

LinusDierheimer commented 2 years ago

Keep the previous line commented, so it surely starts with the implementation to test.

AdisonCavani commented 2 years ago

First commented:

2

Second commented:

3

Removed if statement:

all commented

AdisonCavani commented 2 years ago

Previously I was using a AUR package, not compiling myself

LinusDierheimer commented 2 years ago

Hot guess, but replace the DRM line with a puts("Would use DRM");, leaving the if as is.

AdisonCavani commented 2 years ago

replacement

LinusDierheimer commented 2 years ago

Does the error still occur with fastfetch --set resolution=setval? If no, most probably the DE code is to blame.

AdisonCavani commented 2 years ago

space

LinusDierheimer commented 2 years ago

This means the error is in the WM / DE detection code, which sadly is used by half of the output, so we can't simple disable it part by part to find the issue. Best thing would be to use a debugger like gdb.

AdisonCavani commented 2 years ago

args

LinusDierheimer commented 2 years ago

Yea i forgot that wm and de is detected anyway, as things like theme, icons, font, etc depend on it.

LinusDierheimer commented 2 years ago

Inactive. Still be looking after it.

CarterLi commented 2 years ago

I'm encountering this issue

This means the error is in the WM / DE detection code, which sadly is used by half of the output, so we can't simple disable it part by part to find the issue. Best thing would be to use a debugger like gdb.

* thread #1, name = 'flashfetch', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x00007ffff7f25f29 libc.so.6`__strcasecmp_l_avx + 69
    frame #1: 0x0000555555560ea2 flashfetch`applyPrettyNameIfWM(result=0x0000555555575760, processName=0x000000000000008
    frame #2: 0x0000555555561848 flashfetch`getWMDE(instance=0x00007fffffffe0c0, result=0x0000555555575760) at detectWM5
    frame #3: 0x0000555555561c15 flashfetch`ffDetectWMDE(instance=0x00007fffffffe0c0) at detectWMDE.c:405:9
    frame #4: 0x0000555555566de8 flashfetch`ffPrintCursor(instance=0x00007fffffffe0c0) at cursor.c:178:32
    frame #5: 0x00005555555584d4 flashfetch`main(argc=<unavailable>, argv=<unavailable>) at flashfetch.c:30:5
    frame #6: 0x00007ffff7df0b25 libc.so.6`__libc_start_main + 213
    frame #7: 0x000055555555857e flashfetch`_start + 46

https://github.com/LinusDierheimer/fastfetch/blob/8cb3ff7c2bfffe8da4a7745ef0c7a5640aba39a1/src/common/detectWMDE.c#L69

processName is NULL

CarterLi commented 2 years ago

I managed to make it working by removing lots of features.

diff --git a/src/flashfetch.c b/src/flashfetch.c
index 5a293bc..3306388 100644
--- a/src/flashfetch.c
+++ b/src/flashfetch.c
@@ -14,7 +14,7 @@ int main(int argc, char** argv)
     ffStrbufSetS(&instance.config.color, instance.config.logo.colors[0]); //Use the primary color of the logo as key color

     //Multithreading --> better performance
-    ffStartDetectionThreads(&instance);
+    //ffStartDetectionThreads(&instance);

     //Does things like disabling line wrap
     ffStart(&instance);
@@ -28,14 +28,6 @@ int main(int argc, char** argv)
     ffPrintUptime(&instance);
     ffPrintPackages(&instance);
     ffPrintShell(&instance);
-    ffPrintResolution(&instance);
-    ffPrintDesktopEnvironment(&instance);
-    ffPrintWM(&instance);
-    ffPrintWMTheme(&instance);
-    ffPrintTheme(&instance);
-    ffPrintIcons(&instance);
-    ffPrintFont(&instance);
-    ffPrintCursor(&instance);
     ffPrintTerminal(&instance);
     ffPrintTerminalFont(&instance);
     ffPrintCPU(&instance);

While some sections didn't seem to be right.

image