flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.52k stars 287 forks source link

MangoHud-0.7.2 - Segfaults on any use #1466

Open r-a-sattarov opened 3 weeks ago

r-a-sattarov commented 3 weeks ago

Describe the bug Immediately segfaults when being used in any games I've tried. Previosly used version 0.6.9-1, and don't have this error.

List relevant hardware/software information

Additional context Also tried 29898dbd0869a806ca9fabbb44ffd4db2a4011f6-commit (2024.10.15), and have the same bug.

GDB-logs: gdb-mangohud-0.7.2-opengl.log gdb-mangohud-0.7.2-vulkan.log gdb-mangohud-2024.10.15-vulkan.log

Update: Compiled in debug and run. gdb-mangohud-0.7.2-debug-opengl.log gdb-mangohud-0.7.2-debug-vulkan.log

flightlessmango commented 1 week ago

Works without crashing on latest for me. could you test with latest to confirm?

r-a-sattarov commented 1 week ago

Works without crashing on latest for me. could you test with latest to confirm?

Hi! Tried 1d19d431f185ae2065bb456b619471e1d650c5b0-commit (2024.10.29), and still have the same bug.

Compiled in debug and run. gdb-mangohud-2024.10.29-debug-vulkan.log

r-a-sattarov commented 1 week ago

This error has appeared since version 0.7.0. On version 0.6.9-1, everything works without errors.

Compiled in debug and run. gdb-mangohud-0.7.0-debug-opengl.log gdb-mangohud-0.7.0-debug-vulkan.log

flightlessmango commented 1 week ago

what is your mangohud config file?

r-a-sattarov commented 1 week ago

what is your mangohud config file?

I don't have a ~/.config/MangoHud/MangoHud.conf file in my home directory. I tried to copy the example files there (MangoHud.conf and presets.conf), but it didn't help.

r-a-sattarov commented 1 week ago

I found out that I have an error after this cd05d1771fb60def6aaec49a432f612afb030d1b-commit. Everything was still working on the previous f66700296b3b34f54571d473e82ac9d5932a759c-commit.

@ForTheReallys It seems to me that some features in the presets implementation are now causing this error for me.

ForTheReallys commented 1 week ago

@r-a-sattarov Not in front of my computer at the moment, but just to be clear, it segfaults immediately on launch?

r-a-sattarov commented 1 week ago

@r-a-sattarov Not in front of my computer at the moment, but just to be clear, it segfaults immediately on launch?

Yep. I only see a debug-message about MangoHud version, and then the game crashes.

kosumosu commented 2 days ago

This line looks suspicious to me since it uses designated initialization, but it is only supported since C++20, while MangoHUD uses C++14, if I'm not mistaken. Thus we can not be sure, compiler initializes each field to it's default value. I suspect, that failing media_player_name string was not properly initialized because of that, and SEGFAULTs when reassigned.

I would suggest trying such code instead:

*params = {};
params->preset = use_existing_preset ? params->preset : default_preset;

It uses 'legit' empty braced list, which should initialize everything to zero or with default constructor.

r-a-sattarov commented 1 day ago

I would suggest trying such code instead:

*params = {};
params->preset = use_existing_preset ? params->preset : default_preset;

Thanks! Yep, with these changes, everything is working now (it fixed cd05d1771fb60def6aaec49a432f612afb030d1b-commit).

kosumosu commented 1 day ago

I'm sorry, the more proper fix would be something like this:

auto preset = std::move(params->preset);
*params = {};
params->preset = use_existing_preset ? std::move(preset) : default_preset;