Skip to content
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

wrap simple function pointers #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Habbie
Copy link
Collaborator

@Habbie Habbie commented Apr 18, 2018

This avoids the usage of lightuserdata, which in turn avoids crashes in LuaJIT on many Linux/ARM64 setups.

@@ -2272,16 +2272,24 @@ struct LuaContext::Pusher<TReturnType (TParameters...)>
// when the lua script calls the thing we will push on the stack, we want "fn" to be executed
// since "fn" doesn't need to be destroyed, we simply push it on the stack

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
// we wrap the function pointer so we can store it in a userdata

lua_pushlightuserdata(state, reinterpret_cast<void*>(fn));
// we make a userdata to hold the function's address
auto wrapper = (struct wrap *) lua_newuserdata(state, sizeof(void*));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
// and we store the function pointer inside it

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.

1 participant