-
Notifications
You must be signed in to change notification settings - Fork 25
Patch undefined behavior stuff #243
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
base: development
Are you sure you want to change the base?
Patch undefined behavior stuff #243
Conversation
Undefined sanitizer's complaint: ../external/sources/SDL3-3.2.10/src/events/SDL_eventwatch.c:72:17: runtime error: call to function RTE::WindowMan::HandleWindowExposedEvent(void*, SDL_Event*) through pointer to incorrect function type 'bool (*)(void *, union SDL_Event *)' /media/ext_hdd/nobackup/architector4/Downloads/Cortex-Command-Community-Project/builddebug/../Source/Managers/WindowMan.cpp:678: note: RTE::WindowMan::HandleWindowExposedEvent(void*, SDL_Event*) defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../external/sources/SDL3-3.2.10/src/events/SDL_eventwatch.c:72:17
Undefined sanitizer's complaint: ../Source/Menus/ScenarioActivityConfigGUI.cpp:101:59: runtime error: load of value 190, which is not a valid value for type 'bool' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../Source/Menus/ScenarioActivityConfigGUI.cpp:101:59 ...While working on this one, I discovered that C++ "default-initializes" class members, which leaves primitives and pointers with undefined garbage values, but properly initializes classes. And also the [Most vexing parse](https://en.wikipedia.org/wiki/Most_vexing_parse). Wow.
Undefined sanitizer's complaint: ../Source/System/PathFinder.cpp:176:54: runtime error: 3.40282e+38 is outside the range of representable values of type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../Source/System/PathFinder.cpp:176:54 ...Also change a comment slightly lol
The door hinge still spins up and explodes just fine with this patch applied, as code below lerps it downward properly anyway. Undefined sanitizer complaint: ../Source/Entities/ADoor.cpp:470:24: runtime error: signed integer overflow: 671088640 * 4 cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../Source/Entities/ADoor.cpp:470:24
HeliumAnt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catches!
You can come by the discord if you need help/feedback/etc. btw. (If you don't use discord that's totally fine)
I don't use Discord much at all (only as a browser tab lmao), but decided to join anyway. Immediately after joining it locked my account out entirely asking for phone number verification and insists that my real correctly typed phone number is invalid. Well, I tried. edit: Turns out, installing Discord then doing verification with exact same phone number then deleting discord immediately after helped. Guess I'm there now lol |
I ran the game with the undefined behavior sanitizer and played for an hour or two and found a few small undefined behavior things happening.
Some of them come from Allegro's
_parallelogram_mapfunction which apparently does a divide-by-zero and then multiplying withINT_MAX, and lot come from LuaJIT. A few came from the game code itself, which is what I patched up here.