Earlier quoted context omitted.
User has working software. User updates operating system. User has broken software. That's a problem for the party trying to sell operating system updates.
The software was fundamentally broken before the OS update. It was working by pure random chance with undefined behaviour. It’s a C++ issue, not an OS issue. The same code compiled for another OS would have different random results.
How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
271–280 of 315 posts
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#272Am I the only one to be annoyed by this...? while (this->m_fBladeAngle > 6.2831855) { this->m_fBladeAngle = this->m_fBladeAngle - 6.2831855; } Like, "let's just write a while loop that could turn into an infinite loop coz I'm too lazy to do a division"
I want to assume that the GTA developers did this hack because it was faster than floating point division on the Playstation 2 or something. But knowing they were able to they were able to blow up loading GTA5 by 5 minutes by just parsing json with sscanf, I don't have much hope.
The second error of deduplicating values by linear scanning an array was way more egregious.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#273Earlier quoted context omitted.
I interpret "don't allow unintialized locals when declared" as meaning that this call: int n = scanf("%d %d %d", &x, &y, &z); Would be caught, because it takes references to undeclared variables. To be allowed, the programmer would have to initialize the variables beforehand.
Then people would complain about the wasteful initialisation of out-params. Foolishly, perhaps
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#274IMHO, if something isn’t part of the contract, it should be randomized. Eg if iteration order of maps isn’t guaranteed in your language, then your language should go out of its way to randomize it. Otherwise, you end up with brittle code: code that works fine until it doesn’t.
one might argue that one of the advantages of languages like C is that you only pay for the features you choose to use, no unnecessary overhead like initializing unused variables
Also, scanf should be deprecated. Terrible API. Never use scanf or sscanf etc. We managed to get "gets()" deprecated, time to spread that to other parts of the API.
atoi() or atof() etc. work OK, but really you need a parser.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#275> all these findings prove that the bug is NOT an issue with Windows 11 24H2, as things like the way the stack is used by internal WinAPI functions are not contractual and they may change at any time, with no prior notice. This reminds me of an excellent article I read a while back, the gist of it was that, given sufficient success, there's no such thing as a private API.
I know there’s an XKCD comic about this
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#276My takeaway, speaking as someone who leans towards functional programming and immutability, is "this is yet another example of a mutability problem that could never happen in a functional context" (so, for example, this bug would have never been created by Rust unless it was deeply misused)
Could you elaborate? I cannot see how a functional programming language would have protected you from reading a non existing value while not providing a default
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#277> all these findings prove that the bug is NOT an issue with Windows 11 24H2, as things like the way the stack is used by internal WinAPI functions are not contractual and they may change at any time, with no prior notice. The real issue here is the game relying on undefined behavior (uninitialized local variables), and to be honest, I’m shocked that the game didn’t hit this bug on so many OS versions, although as I…
Other than C#, there is no reason to use those other languages for game dev. Unless the game is fairly simple, or you want to risk a fairly long project by employing a language that hasn't been proven in tge space yet (Rust). No shade at any of those languages, I don't even like C#, just being pragmatic.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#278IMHO, if something isn’t part of the contract, it should be randomized. Eg if iteration order of maps isn’t guaranteed in your language, then your language should go out of its way to randomize it. Otherwise, you end up with brittle code: code that works fine until it doesn’t.
I once updated a little shy of 1mloc of Perl 5.8 code to run on Perl 5.32 (ish). There were, overall, remarkably few issues that cropped up. One of these issues (that showed itself a few times) was more or less exactly this: the iteration order through a hash is not defined. It has never been defined, but in Perl 5.8 it was consistent: for the same insertion order of the same set of keys, a hash would always iterate…
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#279It blows my mind that the languages allow you to leave variables uninitialized which has caused countless bugs (including production bugs that I have seen first hand), and you often need to rely on additional compiler flags or static analysis tools/valgrind etc to catch them. Even though newer languages often use a different solution (default zero value or must initialize a variable before use), people still go back to C/C++ all the time.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#280> all these findings prove that the bug is NOT an issue with Windows 11 24H2, as things like the way the stack is used by internal WinAPI functions are not contractual and they may change at any time, with no prior notice. This reminds me of an excellent article I read a while back, the gist of it was that, given sufficient success, there's no such thing as a private API.
I know there’s an XKCD comic about this