Skip to content

Conversation

@Architector4
Copy link
Contributor

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_map function which apparently does a divide-by-zero and then multiplying with INT_MAX, and lot come from LuaJIT. A few came from the game code itself, which is what I patched up here.

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
@Architector4 Architector4 changed the title Patch undefined stuff Patch undefined behavior stuff Dec 3, 2025
Copy link
Contributor

@HeliumAnt HeliumAnt left a 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)

@Architector4
Copy link
Contributor Author

Architector4 commented Dec 5, 2025

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

HeliumAnt
HeliumAnt previously approved these changes Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants