Facepunch / garrysmod-issues

Garry's Mod issue tracker
144 stars 56 forks source link

Material() crash on native Linux #5652

Open MattJeanes opened 10 months ago

MattJeanes commented 10 months ago

Details

I have been seeing a crash related to material loading in a VGUI context fairly (but not 100%) consistently under certain conditions but only when using native Linux, under Proton or a real Windows machine it works fine.

Note: Running x86-64 branch and using https://github.com/solsticegamestudios/GModCEFCodecFix

Here is an example stack trace - I have emailed over full dmp and log files as requested:

-Lua Stack Traces-
==================
  Client
    0. Material - [C]:-1
      1. SetImage - lua/vgui/dimage.lua:99
        2. LoadScreenUI - addons/tardis/lua/tardis/sh_screen_ui.lua:362
          3. LoadScreen - addons/tardis/lua/tardis/sh_screen_ui.lua:767
            4. LoadScreens - addons/tardis/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua:75
              5. v - addons/tardis/lua/entities/gmod_tardis_interior/modules/sh_interior_screens.lua:90
                6. CallHook - addons/tardis/lua/entities/gmod_tardis_interior/shared.lua:49
                  7. func - lua/entities/gmod_door_exterior/cl_init.lua:38
                    8. (null) - lua/includes/extensions/net.lua:38

Code of interest: https://github.com/MattJeanes/TARDIS/blob/33baf7c9e40fcce95bc34a2306d9b4c99064beec/lua/tardis/sh_screen_ui.lua#L317

Steps to reproduce

This is a bit of an interesting repro, so please bear with on this one - it seems to most reliably happen with these steps in my testing:

  1. Start with a completely fresh GMod install
  2. Switch to x86-64 branch
  3. Install GModCEFCodecFix
  4. Install the following addons a. Jazztronauts b. Doors or on (GitHub) (Note: If loading from GitHub you will also need world-portals) c. TARDIS or on (GitHub)
  5. Load up the Jazztronauts gamemode on the jazz_bar map using a local server (2+ players)
  6. Spawn a TARDIS using the following console command while looking at nearby ground: a. lua_run TARDIS:SpawnTARDIS(player.GetAll()[1], {metadataID = "default"}, true)
  7. If the game did not already crash at this point, enter the TARDIS by pressing USE and walking through the portal or pressing WALK+USE on it
  8. changelevel gm_construct
  9. Once loaded back in, spawn a TARDIS again using the same command as earlier
  10. The game should now crash if it did not already a. If it did not crash, try again from the top, but this almost always seems to trigger the crash for me

I have debugged the particular texture it was trying to load by replacing it with different textures and even removing that call entirely but it will just crash later on in the code when it tries to do DImage:SetImage somewhere else e.g. on some icons.

From what I can tell this is an engine bug as it crashes in native code while trying to call Material(), only happens on Linux (and I believe also macOS). I have seen this happen on pure sandbox without a changelevel, but running under Jazztronauts and the changelevel seem to make it much, much more likely to happen.

We've had reports of crashes around this for several years, but until now I've not been able to get a reliable repro of it to report / investigate it. This was tested on an up to date Steam Deck in desktop mode, but should happen on any Linux machine.

Please let me know if you need any more info to help diagnose what on earth is going on here. Thanks!

mgetJane commented 6 months ago

i've encountered this too in other yet similar circumstances, even on the main branch, i'll see if i can figure out an easier reproduction

i've also never had it happen until some time around mid-2023

mgetJane commented 6 months ago

also this is also probably a bug related to DImage:SetMaterial() or DImage:DoLoadMaterial() rather than _G.Material()