KMQuake2 Crash

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

KMQuake2 Crash

Post 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. :)
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: KMQuake2 Crash

Post 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.
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: KMQuake2 Crash

Post by qbism »

Has anyone dug into the quake2vr fork? Some frame rate improvements and nice projection shadows. Oculus optional.
Barnes
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow
Contact:

Re: KMQuake2 Crash

Post 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
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: KMQuake2 Crash

Post 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.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: KMQuake2 Crash

Post 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. :)
Post Reply