X Tutup
Skip to content

Fix builds which use "-DDEBUG"#5946

Merged
sturnclaw merged 4 commits intopioneerspacesim:masterfrom
mwerle:bug/fix_lua_debug
Nov 4, 2024
Merged

Fix builds which use "-DDEBUG"#5946
sturnclaw merged 4 commits intopioneerspacesim:masterfrom
mwerle:bug/fix_lua_debug

Conversation

@mwerle
Copy link
Contributor

@mwerle mwerle commented Nov 3, 2024

Thanks to @WickedSmoke (IRC) for pointing out that the debug builds were broken when "-DDEBUG" is specified as part of the build.

Specifically, "DEBUG" enables the "LUA_DEBUG" symbols, and these no longer compile in the current codebase. This patch fixes the compilation errors, but, notably, now cause runtime problems such as:

Pioneer/src/lua/LuaVector.cpp:240: lua stack difference is 1, expected 0

This patch also replaces all instances of checking "DEBUG" with checks against "NDEBUG" instead, as the latter is part of the C/C++ language standards and thus independant of any particular build system.

mwerle and others added 4 commits November 3, 2024 07:50
When the "DEBUG" build macro is supplied during a build, the
"LUA_DEBUG_xxx" macros are enabled. These macros rely on some
functionality in "Log.h", which has been lost in some source files
during various refactrors over the years.

This patch adds these back in, as well as fixing a couple of instances
where the LUA_DEBUG_xx macros themselves were no longer working.

NOTE: This patch only fixes the compile-time errors. When running with
"DEBUG" enabled, various LUA_DEBUG_xx macros fail at runtime, indicating
either that the invariants they check are no longer true and must be
updated, or that a bug has been introduced in the code in the meantime.
- Fix extra metatype object being left on the stack in unwanted cases
- Fix extra load of the global IO namespace in Sandbox.cpp
- Fix error where we tried to validate the presence of one more value on the stack than we actually wanted
Also add missing validation to LuaObjectBase::PushRegister()
@mwerle mwerle force-pushed the bug/fix_lua_debug branch from d472978 to 3ccb261 Compare November 3, 2024 04:11
Copy link
Member

@sturnclaw sturnclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, and I think we've caught most if not all of the runtime errors associated with failed checks.

Thanks for tackling this @mwerle and thanks WickedSmoke for reporting it in the first place!

@sturnclaw sturnclaw merged commit 628f39c into pioneerspacesim:master Nov 4, 2024
@mwerle mwerle deleted the bug/fix_lua_debug branch November 4, 2024 23:06
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

X Tutup