Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exits with a segfault instead of vpo #48

Closed
chocolate-import opened this issue Dec 8, 2013 · 8 comments
Closed

exits with a segfault instead of vpo #48

chocolate-import opened this issue Dec 8, 2013 · 8 comments

Comments

@chocolate-import
Copy link

The following bug was originally reported on Sourceforge by gammafactorial, 2008-09-29 22:26:47:

chocolate-doom -file shdwpit.wad -warp 01 exits with a segmentation fault instead of the visplane overflow message like the exe

@jmtd
Copy link
Contributor

jmtd commented Sep 8, 2015

@fabiangreffrath
Copy link
Member

This happens because R_CheckPlane() does not have a check if MAXVISPLANES is reached before making a new one and R_FindPlane() only checks for (lastvisplane - visplanes == MAXVISPLANES), not >=.

@jmtd jmtd added the confirmed label Sep 8, 2015
@mfrancis95
Copy link
Contributor

You can add a NULL check to the visplane in R_CheckPlane and error out early, and this seems to catch it, but I don't think this is the most ideal way of solving the issue.

diff --git a/src/doom/r_plane.c b/src/doom/r_plane.c
index 16dde4c2..db882e57 100644
--- a/src/doom/r_plane.c
+++ b/src/doom/r_plane.c
@@ -266,7 +266,11 @@ R_CheckPlane
     int		unionl;
     int		unionh;
     int		x;
-	
+    if (pl == NULL)
+    {
+        I_Error ("R_DrawPlanes: visplane overflow (%" PRIiPTR ")",
+         lastvisplane - visplanes);
+    }
     if (start < pl->minx)
     {
 	intrl = pl->minx;

@fabiangreffrath
Copy link
Member

A pointer pointing past the visplanes[] array isn't necessarily a NULL pointer.

--- a/src/doom/r_plane.c
+++ b/src/doom/r_plane.c
@@ -307,6 +307,9 @@ R_CheckPlane
     lastvisplane->picnum = pl->picnum;
     lastvisplane->lightlevel = pl->lightlevel;
     
+    if (lastvisplane - visplanes == MAXVISPLANES)
+       I_Error ("R_CheckPlane: no more visplanes");
+
     pl = lastvisplane++;
     pl->minx = start;
     pl->maxx = stop;

@mfrancis95
Copy link
Contributor

So @fabiangreffrath could that be merged in? Is there anything else that would need to be done?

@fabiangreffrath
Copy link
Member

I expressed some objections against your approach, but have none against mine. 😉 Could you confirm that it works as expected?

@AXDOOMER
Copy link
Contributor

Is something else than the VPO wrong with this map? It won't even run in Doom+. It locks up with the music playing, either there's a missing player 1 start position or there's more than 1024 visplanes. I don't have tools to check.

@AXDOOMER
Copy link
Contributor

@fabiangreffrath I implemented your fix in my source port and it works as expected.

AXDOOMER/doom-vanille@56ccf3a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants