ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.55k stars 552 forks source link

[BUG] Game can segfault if your mod has and archive inside another archive #2622

Open emileb opened 4 months ago

emileb commented 4 months ago

GZDoom version

master as of today

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Windows 11

Please describe your specific OS version

No response

Relevant hardware info

No response

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

When some resources are loaded in-game by one of the render threads, and the resource is an archive INSIDE ANOTHER ARCHIVE, it will attempt to open an invalid file name which causes a null mReade inside FileReader and ultimately a crash.

For example it will try to open this string as a real file with fopen:

"/Doom/mods/Project Brutality.zip:2. badass sounds.wad"

This can be 'fixed' by setting gl_multithread to 0 when reading graphics.

It also crashes when the audio resource is inside a WAD which is inside a PK3

If this is true and it's a WAD inside a PK3 it might crash:

if (readertype == READER_NEW || !mainThread)

Line here:

https://github.com/ZDoom/gzdoom/blob/0caa036a96a24f47964cddb57906d5b51f71ac1e/src/common/filesystem/source/resourcefile.cpp#L704

To reproduce, load this mod with Doom 2, enter a new game and start shooting: https://drive.google.com/file/d/1jC-bD4vqVprV5yiFnhkbxt6CjllivXA4/view?usp=sharing

Steps to reproduce the behaviour.

To reproduce, load this mod with Doom 2, enter a new game and start shooting:

https://drive.google.com/file/d/1jC-bD4vqVprV5yiFnhkbxt6CjllivXA4/view?usp=sharing

Your configuration

Default

Provide a Log

No response

MajorCooke commented 4 months ago

There's a warning for those who have such structures. This applies no matter what the archive type is, except for maps. Whoever is responsible, they should unpack the mod appropriately and put things in the proper folders.

emileb commented 4 months ago

There's a warning for those who have such structures. This applies no matter what the archive type is, except for maps. Whoever is responsible, they should unpack the mod appropriately and put things in the proper folders.

Thanks for the info, yeah this isn't me making the mod was just reported to me by someone who said it was OK on 4.11, so I checked it out. In this case it isn't a performance issue but causes a seg fault due to recent changes. Can close if more appropriate! Thanks.

MajorCooke commented 4 months ago

Best let a developer take a look at this first, who knows if anything can be improved on the engine side, though I doubt it.