Page 2 of 2

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

PostPosted: Wed May 16, 2018 2:18 am
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 allExpand view
#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...

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

PostPosted: Wed May 16, 2018 3:13 am
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.

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

PostPosted: Wed May 16, 2018 4:07 am
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

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

PostPosted: Wed May 16, 2018 4:14 am
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.

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

PostPosted: Wed May 16, 2018 4:22 am
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.

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

PostPosted: Wed May 16, 2018 4:27 am
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.

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

PostPosted: Wed May 16, 2018 7:11 am
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.

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

PostPosted: Wed May 16, 2018 8:37 am
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?

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

PostPosted: Wed May 16, 2018 8:44 am
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.

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

PostPosted: Wed May 16, 2018 8:55 am
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.

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

PostPosted: Wed May 16, 2018 1:47 pm
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).

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

PostPosted: Wed May 16, 2018 2:11 pm
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.

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

PostPosted: Wed May 16, 2018 2:44 pm
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!

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

PostPosted: Wed May 16, 2018 3:21 pm
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.