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
{{ message }}
Repository navigation
lua_getinfo and lua_getstack incorrect parameters #33
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;
}
Activity
tilkinsc commentedon Nov 23, 2025
I propose it to look like this
Since you can just use a ref here. No need to manually allocate it, since that is handled already.
Do you have anything against doing it this way?
tilkinsc commentedon Nov 23, 2025
Woopsie wrong one
1xKvSUbAg1xJx9KutZW1lzrdGImI3CaW commentedon Nov 24, 2025
The only problem doing it this was is that the strings wont be marshelled properly, perhaps use libraryimport and have sourcegen deal with it?
tilkinsc commentedon Dec 9, 2025
I've never had a problem with the strings marshalling as parameters. Only when they are returned from a function.