Skip to content

wrap simple function pointers#45

Open
Habbie wants to merge 1 commit intoahupowerdns:masterfrom
PowerDNS:wrap-simple-function-pointers
Open

wrap simple function pointers#45
Habbie wants to merge 1 commit intoahupowerdns:masterfrom
PowerDNS:wrap-simple-function-pointers

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