Can't get GZDoom to compile and run (Windows 10)

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Can't get GZDoom to compile and run (Windows 10)

Post by _mental_ »

It's here. This can happen only if _get_pgmptr() function returns zero but for some reason assigns nullptr to its argument.

Code: Select all

#ifdef _MSC_VER
		if (_get_pgmptr(&program) != 0)
		{
			I_FatalError("Could not determine program location.");
		}
#else
		// ...
#endif
		progdir = program;
		program = progdir.LockBuffer();
		*(strrchr(program, '\\') + 1) = '\0';   // <------
		//... 
EDIT: The crash is caused by a new Windows SDK, 10.0.17134.0 in my case. _get_pgmptr() assigns an empty string to its argument. Looks like Microsoft cannot release anything that won't break existing software. It's a new trend in software industry and everyone wants to be a part of it...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Graf Zahl »

The real error here is assuming that 'strrchr' always returns something valid and usable. You do not code like that!!!
This would already crash if the file name contained forward slashes or no slashes at all.

Just remove that case and always use GetModuleFileName. I don't get it why such a totally redundant special case needs to be here and why it is necessary to check some CRT internal here.
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3141
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by drfrag »

Luckily this kind of stuff doesn't happen with MinGW. :mrgreen:
But now seriously according to Monkeysoft _get_pgmptr should not return zero when pValue is NULL but EINVAL.
https://msdn.microsoft.com/en-us/library/24awhcba.aspx
Cacodemon345
Posts: 419
Joined: Fri Dec 22, 2017 1:53 am
Graphics Processor: ATI/AMD (Modern GZDoom)
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Cacodemon345 »

EDIT: The crash is caused by a new Windows SDK, 10.0.17134.0 in my case. _get_pgmptr() assigns an empty string to its argument. Looks like Microsoft cannot release anything that won't break existing software. It's a new trend in software industry and everyone wants to be a part of it...
That's another time Microsoft fixed up another undefined behaviour, ever since older DDraw games started to break...
That's the reason why I prefer older Win7.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Graf Zahl »

Which wouldn't help you in any way here, because it's not an error in the operating system but in some library code that got linked into GZDoom that caused the problem.
In all seriousness, why was this function even used? IMO it's a classic case of bad app code causing problems down the line because it wasn't fully thought through.

Fun stuff: Before 2008 this was using GetModuleFileName but then Randi must have read about this strange function and changed the code without any real need. Then later problems on MinGW surfaced and the #ifdef got added. And now we're back to the start, as it always should have remained.
Last edited by Graf Zahl on Wed May 16, 2018 3:33 am, edited 1 time in total.
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3141
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by drfrag »

Now i see the program is expected to crash anyway and to allow it to continue a custom invalid parameter handler would be required.
Cacodemon345
Posts: 419
Joined: Fri Dec 22, 2017 1:53 am
Graphics Processor: ATI/AMD (Modern GZDoom)
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Cacodemon345 »

Graf Zahl wrote:bad app code
...is the reason why a lot of Windows games in the 90s no longer work anymore, due to bad coding shit.
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: Can't get GZDoom to compile and run (Windows 10)

Post by RockstarRaccoon »

So, we were right? This isn't a problem with anything I'm doing, the code just doesn't work anymore? So, I should either change that line or use the Linux compiler? Has this been fixed in the latest GitHub build?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Graf Zahl »

Yes, _mental_ has committed a fix a few hours ago.
You would actually be able to compile it if CMake allowed selection of the desired Windows SDK.
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: Can't get GZDoom to compile and run (Windows 10)

Post by RockstarRaccoon »

Well, it's a new computer, so I don't have the older Windows SDKs on it, so the fix is preferable. I'm assuming I would get that from the gitHub version? Yep.
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3141
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by drfrag »

If you want to make some modifications to the code you should install Git and TortoiseGit.
That said you could also check that commit and copy-pasta the changes in your source manually.
I was wrong and the link i provided earlier was for an older version, i still don't know where the code for 3.3.2 is in the repo.
Right now AFAIK there are a couple of branches with the fix applied, the official master https://github.com/coelckers/gzdoom/archive/master.zip and my unofficial MinGW maintenance branch https://github.com/drfrag666/gzdoom/archive/g3.3mgw.zip (this is mostly up to date minus the 2D and GL refactor).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can't get GZDoom to compile and run (Windows 10)

Post by Graf Zahl »

drfrag wrote: I was wrong and the link i provided earlier was for an older version, i still don't know where the code for 3.3.2 is in the repo.
It's at the g3.3.2 tag, where else? If you just look at master's history you won't find it. The release tags will always be off the mainline because of the versioning info they need.
User avatar
RockstarRaccoon
Posts: 598
Joined: Sun Jul 31, 2016 2:43 pm

Re: Can't get GZDoom to compile and run (Windows 10)

Post by RockstarRaccoon »

Alright, new code is building fine on my computer! Thanks for all the help guys, and glad that I ended up helping you find an error! :3

Working on that AutoMap stuff I wanted to test now. Hope to be trying to get it in the main build soon!
User avatar
drfrag
Vintage GZDoom Developer
Posts: 3141
Joined: Fri Apr 23, 2004 3:51 am
Location: Spain
Contact:

Re: Can't get GZDoom to compile and run (Windows 10)

Post by drfrag »

Thanks, that tag is not on any branch and i was missing tags in my local repo.

Then you'll need Git and to work on the current master.
Post Reply

Return to “General”