Skip to content

Conversation

@tritao
Copy link
Contributor

@tritao tritao commented Nov 4, 2024

Fixes an regression introduced in afcbbb2.

require actually follows a different code path in Lua with a different stack layout expectation than the other code paths.

Fix the code to deal with this case, and also clean up some other tidbits around cleaning up stack values. The new approach is simpler to understand and should fix a potential issue that could happen in the error case.

Fixes #2314.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

@tritao tritao force-pushed the fix-loadfile-require branch from eed8e2d to e28985b Compare November 4, 2024 05:00
Fixes an regression introduced in
premake@afcbbb2.

`require` actually follows a different code path in Lua with a different
stack layout expectation than the other code paths.

Fix the code to deal with this case, and also clean up some other
tidbits around cleaning up stack values. The new approach is simpler to
understand and should fix a potential issue that could happen in the
error case.

Fixes premake#2314.
@tritao tritao force-pushed the fix-loadfile-require branch from e28985b to 7fcf9dd Compare November 4, 2024 05:09
@tritao tritao marked this pull request as ready for review November 4, 2024 05:11
* script chunk on the stack. Turn these into a closure that will call my
* wrapper below when the loaded script needs to be executed. */

assert(lua_gettop(L) == bottom + 2);
Copy link
Member

Choose a reason for hiding this comment

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

Do we want an assertion failure here, or should we report the error more gracefully somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think assert is probably the correct thing to do here, this is basically a sanity check on my part. Assert messages are only fired up in debug mode anyway, so should make no difference to users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we end up having any more issues here, I can look into doing something more involved but for now I think this is good enough.

@nickclark2016
Copy link
Member

Please go ahead and ping me whenever you push up for this/reply to comments. Once we get this in, I'll be getting a release together.

@tritao
Copy link
Contributor Author

tritao commented Nov 10, 2024

Please go ahead and ping me whenever you push up for this/reply to comments. Once we get this in, I'll be getting a release together.

Replied to your comment. @nickclark2016

@nickclark2016 nickclark2016 self-requested a review November 10, 2024 01:01
@nickclark2016 nickclark2016 merged commit c07ea89 into premake:master Nov 10, 2024
15 checks passed
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.

Using require in user scripts crashes premake

3 participants