You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From a quick glance at the Lua sources, it may be possible to override the use of assert.h for the API check with a custom function. If so, this would make api checks much more easy to debug with zig panics and stack traces.
And while we are here, should we make it possible to define LUA_USE_APICHECK manually (so it can be always on, or on in all safe modes?)
this has the advantage that a stack trace is dumped in addition to the Lua library's assertion message. one disadvantage is that if other code (like for example std.debug.panicImpl) calls abort, you might see two stack traces. to guard against this, in seamstress v2 i put the stack trace dump inside a conditional which should only succeed if SIGABRT is raised by something other than std.debug.panicImpl
I agree, this would be a great addition! i guess the #define can be done with an addition to the compiler flags, but the extern declaration might be trickier.
Clang has a -include flag for #including an additional file before parsing. I've used it before but it feels kind of hacky and I'm not sure if it is integrated with zig build. So this might not actually be an option
Create a new run step that outputs the concatenation of the user's custom h file (if any) and the extern and #define and use that as the custom h file.
I think option 2 makes sense and shouldn't be too hard. I'll work on that
Activity
robbielyman commentedon Jun 5, 2024
this is doable from consumer code:
robbielyman commentedon Oct 8, 2024
here's a slightly better solution (zig 0.13, tested only on macOS so far):
this has the advantage that a stack trace is dumped in addition to the Lua library's assertion message. one disadvantage is that if other code (like for example
std.debug.panicImpl) calls abort, you might see two stack traces. to guard against this, in seamstress v2 i put the stack trace dump inside a conditional which should only succeed ifSIGABRTis raised by something other thanstd.debug.panicImplnatecraddock commentedon May 9, 2026
I got this working from consumer code a different way
Then I try to access a stack index that is too high
Before
After
I think this is very useful. I'd like to find a way to do this without using the user_h and maybe enable it by default
robbielyman commentedon May 9, 2026
I agree, this would be a great addition! i guess the
#definecan be done with an addition to the compiler flags, but theexterndeclaration might be trickier.natecraddock commentedon May 10, 2026
I can think of two ways
-includeflag for #including an additional file before parsing. I've used it before but it feels kind of hacky and I'm not sure if it is integrated with zig build. So this might not actually be an optionexternand#defineand use that as the custom h file.I think option 2 makes sense and shouldn't be too hard. I'll work on that