JakobOvrum/LuaD

Type mismatch for struct parameters crashes on Windows

Opened this issue · 0 comments

I'm not sure exactly what's going on behind the scenes, but on Windows, when a D method wrapped in lua expects a struct parameters and has a type mismatch, it causes an assertion failure by changing the stack, and the throwing of this assertion failure spirals out of control and causes a stack overflow.

I haven't been able to get it to do this on Linux, but with DMD 2.070 on Windows 7, I've been able to trigger this with both phobos' default and m32mscoff runtimes. I've also reproduced it with both the included static lua5.1.lib and a custom build of lua 5.1.5.

Here's some example code that causes the problem

import luad.all;
import std.stdio;

struct A {
    int b;
}

void makeassertfail(A value) {
}

void main() {
    auto lua = new LuaState();
    lua.openLibs();
    lua.globals["makeassertfail"] = &makeassertfail;
    lua.doString(`
        print("Testing type mismatch.")
        makeassertfail(0);
    `);
}