Page 1 of 1

KMQuake2 Crash

Posted: Wed Mar 11, 2015 4:26 am
by jitspoe
I was testing my map in KMQuake2, and it crashed on load. I think it might have been because I had the .tga files for the sky, but not the .pcx. I compiled and debugged the engine, and it seemed to have something to do with the precache/CL_RequestNextDownload() code, but I couldn't pinpoint exactly what caused it since it appeared to be a memory stomp.

The command "precache 19622" seems to be the origin of the issue.

Edit: Nope, put some pcx files in there... must be something with the map itself?

I did notice a Com_sprintf overflow error on load. Maybe that's related.

Seems the precache number it crashes on isn't consistent. This time it was "precache 15813".

Edit: Figured out what the problem was, the map filename was too long: inprogress/irishcastle_q2_1p.bsp -- might want to make that not crash. :)

Re: KMQuake2 Crash

Posted: Wed Mar 11, 2015 5:29 pm
by Knightmare
That crash also happens in my latest dev build, but only with release builds. Are you sure it's in CL_RequestNextDownload()?

It also happens in Quake2Max, but not in any other engine.

BTW, Com_sprintf() in KMQ2 is buffer-safe and null-terminated.

EDIT: I debugged Quake2Max instead, and that crash happens in both CL_PrepRefresh() and SCR_DrawLoading(). The former is called from CL_RequestNextDownload().

There's an strcpy() call there with a 32-char buffer (mapname) as a target. Vanilla Q2 3.21 and my v3.24 patch do this as well, but it doesn't crash for me (maybe because they're compiled with MSVC6?).

As luck would have it, I'm currently preparing a new public release of KMQ2. So this will be fixed in a public build soon.

Here are the problem lines in case you want to fix this yourself instead of waiting.

In cl_view.cpp->CL_PrepRefresh(), look for this:

Code: Select all

	strcpy (mapname, cl.configstrings[CS_MODELS+1] + 5);	// skip "maps/"
Replace it with this:

Code: Select all

	Q_strncpyz (mapname, cl.configstrings[CS_MODELS+1] + 5, sizeof(mapname));	// skip "maps/"
You may also want to increase the size of the buffer mapname.

In cl_screen.c->SCR_DrawLoading(), look for this:

Code: Select all

		strcpy (mapfile, cl.configstrings[CS_MODELS+1] + 5);	// skip "maps/"
Replace it with this:

Code: Select all

		Q_strncpyz (mapfile, cl.configstrings[CS_MODELS+1] + 5, sizeof(mapfile));	// skip "maps/"
You may also want to increase the size of the buffer mapfile.

Re: KMQuake2 Crash

Posted: Mon Mar 16, 2015 4:51 pm
by qbism
Has anyone dug into the quake2vr fork? Some frame rate improvements and nice projection shadows. Oculus optional.

Re: KMQuake2 Crash

Posted: Mon Mar 16, 2015 6:11 pm
by Barnes
qbism wrote:Has anyone dug into the quake2vr fork? Some frame rate improvements and nice projection shadows. Oculus optional.
Nice projection shadows? Its default shadow volumes from kmq2

Re: KMQuake2 Crash

Posted: Tue Mar 17, 2015 3:20 am
by qbism
I had forgotten kmq2 projection shadows, turned-off in bad gpu days :( . But even on an old gpu, quake2vr shadows are fast without flicker. Most improvement is small items like gibs... then I noticed q2vr gibs don't even cast shadows. Maybe 'noshadow' shaders in the vr.pk3 or flagged in modified game files.

Anyway, q2vr seems worth diffing for worthwhile fixes/changes, although it might not solve this specific filename crash.

Re: KMQuake2 Crash

Posted: Sun Apr 05, 2015 8:58 am
by jitspoe
Once I figured out it was the long filename causing the crash, I switched to a shorter filename and didn't dig into it any further. I just wanted to make sure you knew so it could be fixed. :)