godot-tbloader icon indicating copy to clipboard operation
godot-tbloader copied to clipboard

Crash when building mesh from certain .map files

Open Muha0644 opened this issue 3 years ago • 4 comments

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"

Muha0644 avatar Nov 09 '22 14:11 Muha0644

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?

codecat avatar Nov 11 '22 14:11 codecat

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

Muha0644 avatar Nov 12 '22 19:11 Muha0644

@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"
}

andreymal avatar Feb 27 '23 02:02 andreymal

Nice catch! Thanks for the tip 😊

codecat avatar Feb 27 '23 11:02 codecat