Crash when building mesh from certain .map files
Rebuilding the mesh with a "bad" .map file reliably causes godot to crash with the following error:
*** stack smashing detected ***: terminated
[1] 28334 IOT instruction (core dumped) "/home/user/bin/godot4"
The issue (from my testing) seems to be entirely preventable in Trenchbroom itself. The crash only happens when a parent folder is loaded in the "texture collection" panel in the "faces" tab in TB. For example, if I have the following folder structure in my project:
/textures
| -/epic_textures
| | -/red
| | | files...
| | -/green
| | | files...
| | -/blue
| | | files...
selecting all the child folders works flawlessly, but if I include epic textures in the TB menu, it causes a crash when building the mesh in godot.
I have verified this by editing the generated .map file using a text editor, removing the parent folder from "_tb_textures" fixes the crash:
-"_tb_textures" "textures/epic_textures;textures/epic_textures/green;textures/epic_textures/blue;textures/epic_textures/red"
+"_tb_textures" "textures/epic_textures/green;textures/epic_textures/blue;textures/epic_textures/red"
Hm, I can't seem to reproduce this (on Windows). Can you post a map file and a folder of textures that can reproduce this?
I've made an example project and tested it, it indeed crashes with the same error. I've tested it on two computers so far. Here is the project: test.zip
@codecat this is probably because the buf[255] array is overflowing.
A minimal .map file that crashes latest TBLoader on my Linux:
{
"mapversion" "220"
"classname" "worldspawn"
"_tb_textures" "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
}
Nice catch! Thanks for the tip 😊