IMHO, 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
How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
141–150 of 315 posts
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#142IMHO, 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.
Then you are wasting runtime clock cycles randomizing lists.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#143Earlier quoted context omitted.
While it doesn't excuse the bad habits, we do have to keep in mind C++98 (or whatever more ancient was used back then) didn't have the simple initializers we now take for granted. You couldn't just do 'Type myStruct = {};' to null-initialize it, you had to manually NULL all nested fields. God forbid you change the order of the variables in the struct if you're nesting them and forget to update it everywhere. It was j…
I haven't been using C++ for a number of years but I think you could set the default values of fields even back then. Something like struct test { int my_int = 0; int* my_ptr = std::nullptr; }; Or is this something more recent ? You cannot initialize them with a different value unless you also write a constructor, but it not the issue here (since you are supposed to read them from the file system)
struct test {
int my_int;
int *my_ptr;
test() : my_int(0), my_ptr(NULL) {}
};Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#144Earlier quoted context omitted.
Undefined behavior to access the uninitialized memory. A sanitizer would have flagged that.
The compiler has no way of knowing that the memory would be undefined, not unless it somehow can verify the data file. The most I think it can do is flag the program for not checking the return value of scanf, but even that is unlikely to be true since the program probably was checking for end of file which is also in the return value. It was failing to check the number of matched parameters. This is the kind of erro…
Yes it would. -fsanitize=address does a bunch of instrumentation - it allocates shadow memory to keep track of what main memory is defined, and it checks every read and write address against the shadow memory. It is a combination of compile-time instrumentation and run-time checking. And yes, it is expensive, so it should be used for debugging and not the final release.
https://clang.llvm.org/docs/AddressSanitizer.html , https://learn.microsoft.com/en-us/cpp/sanitizers/asan?view=m...
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#145My 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)
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#146I wonder if they fixed the vehicle definition file as well, or just the parser. The latter would be an incomplete fix.
A real update should fix both (note: I don't believe the later releases did, they also just added defaults to the parser) but for SilentPatch: a mod is not a real update, and being as simple as possible to remove & reducing conflicts with other mods is more important here than a fix that digs as deep as possible.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#147Earlier quoted context omitted.
I’ll be the first to defend the greybeards I’ve befriended and learned from in AAA, but having seen codebases of that age and earlier, the “meta” around game development was different back then. I think the internet really changed things for the better. Your average hire for the time might have been self-taught with the occasional C89 tutorial book and two years of Digipen. Today’s graduates going into games have fal…
Otoh, the Internet has meant that nothing is ever finished, there's always an update to download.
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#148Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#149Earlier quoted context omitted.
Tools like valgrind/asan/msan would have flagged this instantly too. Just a unit test of that vehicle loader would have seen it. Really this is more a story about poor development practice than it is an interesting bug.
As if tools in early 2000's were any good...
Re: How a 20 year old bug in GTA San Andreas surfaced in Windows 11 24H2
#150IMHO, 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.
Then you are wasting runtime clock cycles randomizing lists.