Skip to content

lua_getinfo and lua_getstack incorrect parameters #33

Description

In the current implementation these are passed to lua as value while they should actually be ptrs for reading data out. One fix could be to replace the struct with an nint and just let .net deal string cancer like this

[DllImport(DllName, CallingConvention = Convention)]
public static extern int lua_getinfo(lua_State L, string what, nint ar);
public static int lua_getinfo(lua_State L, string what, ref lua_Debug ar)
{
nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf<lua_Debug>());
int v;
try
{
v = lua_getinfo(L, what, ptr);
ar = Marshal.PtrToStructure<lua_Debug>(ptr);
}
finally
{
Marshal.FreeHGlobal(ptr);
}
return v;
}

https://www.lua.org/manual/5.1/manual.html#lua_getinfo
https://www.lua.org/manual/5.1/manual.html#lua_getstack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions