Skip to content

Debug hooks not working properly #29

Closed
@TGMM

Description

@TGMM

I'm getting "System.AccessViolationException: Attempted to read or write protected memory" when trying to use the Debug library hooks.
I've tried with all the Lua versions and none of them seem to work, here's a snippet of code that will help reproduce the issue.

using LuaNET.Lua54;
using NativeMethods = LuaNET.Lua54.Lua;

var lua = NativeMethods.luaL_newstate();
NativeMethods.luaL_openlibs(lua);
NativeMethods.lua_sethook(lua, Hook, NativeMethods.LUA_MASKLINE, 0);
NativeMethods.luaL_dostring(lua, "print(10)\nprint(20)\nlocal x = 10");
return;

static void Hook(lua_State state, NativeMethods.lua_Debug func)
{
    Console.WriteLine("Test");
}

The function signature in lua.h does seem to match the bindings, so not sure what could be wrong here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions