ValveSoftware / Source-1-Games

Source 1 based games such as TF2 and Counter-Strike: Source
634 stars 74 forks source link

HL2 vulkan renderer crashes with glibc-2.34 in tcmalloc double free #3729

Open KungFuJesus opened 2 years ago

KungFuJesus commented 2 years ago

It seems that tcmalloc is trying to free an invalid address or one that's already freed. I get the following stack trace:

src/tcmalloc.cc:289] Attempt to free invalid pointer 0xfade340 

Thread 1 "hl2_linux" received signal SIGABRT, Aborted.
0xf7fc9549 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fc9549 in __kernel_vsyscall ()
#1  0xf7da6467 in  () at /lib/libc.so.6
#2  0xf7d56811 in raise () at /lib/libc.so.6
#3  0xf7d40242 in abort () at /lib/libc.so.6
#4  0xf7f4efd2 in tcmalloc::Log(tcmalloc::LogMode, char const*, int, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem) (mode=tcmalloc::kCrash, filename=0xf7f61c62 "src/tcmalloc.cc", line=289, a=..., b=..., c=..., d=...) at src/internal_logging.cc:119
#5  0xf7f4aa0d in (anonymous namespace)::InvalidFree(void*) (ptr=0xfade340) at src/tcmalloc.cc:289
#6  0xf7f5b0b0 in (anonymous namespace)::do_free_with_callback (ptr=0xfade340, invalid_free_fn=<optimized out>) at src/tcmalloc.cc:1121
#7  (anonymous namespace)::do_free (ptr=0xfade340) at src/tcmalloc.cc:1153
#8  tc_free(void*) (ptr=0xfade340) at src/tcmalloc.cc:1499
#9  0xf7b6af1c in operator delete(void*, std::align_val_t) () at /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/32/libstdc++.so.6
#10 0xf7b6af80 in operator delete(void*, unsigned int, std::align_val_t) () at /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/32/libstdc++.so.6
#11 0xebde64a5 in dxvk::DxvkUnboundResources::clearResources(dxvk::DxvkDevice*) () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/libdxvk_d3d9.so
#12 0xebdae00f in dxvk::DxvkDevice::initResources() () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/libdxvk_d3d9.so
#13 0xebd8994f in dxvk::DxvkAdapter::createDevice(dxvk::Rc<dxvk::DxvkInstance> const&, dxvk::DxvkDeviceFeatures) () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/libdxvk_d3d9.so
#14 0xebd16c57 in dxvk::D3D9InterfaceEx::CreateDeviceEx(unsigned int, _D3DDEVTYPE, void*, unsigned int, _D3DPRESENT_PARAMETERS_*, D3DDISPLAYMODEEX*, IDirect3DDevice9Ex**) () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/libdxvk_d3d9.so
#15 0xebd16f02 in dxvk::D3D9InterfaceEx::CreateDevice(unsigned int, _D3DDEVTYPE, void*, unsigned int, _D3DPRESENT_PARAMETERS_*, IDirect3DDevice9**) () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/libdxvk_d3d9.so
#16 0xebfe640a in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/shaderapivk.so
#17 0xebfe667d in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/shaderapivk.so
#18 0xebfe67e7 in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/shaderapivk.so
#19 0xebfcca68 in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/shaderapivk.so
#20 0xf0f48f52 in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/materialsystem.so
#21 0xf1606f54 in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/engine.so
#22 0xf160767e in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/engine.so
#23 0xf16027db in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/engine.so
#24 0xf1603372 in  () at /home/adam/.local/share/Steam/steamapps/common/Half-Life 2/bin/engine.so
#25 0xf63143d8 in  () at bin/launcher.so
#26 0xf63143d8 in  () at bin/launcher.so
#27 0xf62fb29e in LauncherMain () at bin/launcher.so
#28 0x08048564 in main ()

This is with nvidia driver 495.44

KungFuJesus commented 2 years ago

So as others have suggested in other bug reports on here, simply removing the distributed tcmalloc and allowing hl2 to use my distro's tcmalloc made things work again. I do speculate that it could affect trust factor in games with online multiplayer, so I'm hesitant to do it for those. But seems that the distributed tcmalloc with these games is incompatible with newer glibcs?

KungFuJesus commented 2 years ago

See also: https://github.com/ValveSoftware/csgo-osx-linux/issues/2659

bobbyboy5069 commented 1 year ago

Happens in Team Fortress 2 as well. I had to replace the distributed libtcmalloc_minimal.so.4 with a symlink to the native library to get it to work. Seeing as CS:GO now ships an updated tcmalloc library I hope other Source games will be updated as well.