Stack corruption manifested in get_last_error

Issue #17 resolved
juan_batovi
created an issue

OOLua version: 2.0.0

Compiler: Visual Studio C++ 2008

Error message: Run-Time Check Failure #2 - Stack around the variable 'error' was corrupted.

The debugger points to the last line of the following function in the file oolua_error.cpp:

std::string get_last_error(lua_State* vm)

Minimal example:

#include <oolua/oolua.h>

int main(int, char**) {
    OOLUA::Script script;
    std::string chunk = "Force Error";
    if(!script.run_chunk(chunk)) {
        std::string error = OOLUA::get_last_error(script.state());
        std::cout << "Error loading chunk: " << error;
    }
    return 0;
}

Comments (4)

  1. Liam Devine repo owner

    Juan thank you for the report and minimal example. I currently do not have access to vs 2008, yet have tried with both 2013 and 2015 where I have been unable to reproduce this error. I get the expected output for both debug and release builds, these being [string "Force Error"]:1: '=' expected near 'Error' and [string "userChunk"]:1: '=' expected near 'Error' respectively.

    Is there any more information that you could provide about your build settings etc. and are you able to constantly reproduce this error? I will attempt to run with a copy of vs 2008 when I have access, either later tonight or tomorrow.

  2. juan_batovi reporter

    Hi Liam. Thanks for taking a look into this. I tried an empty project with Lua, OOLua and that example and I cannot reproduce the error too. So there must be a problem in the build settings of my project (here the error is always reproducible). I'll let you know if I find something. Thanks again.

  3. juan_batovi reporter

    Hi Liam. I found the problem. I compared my project and the OOLua one (created by me to build the library) and I was using the runtime library "Multi-threaded" instead of "Multi-threaded Debug" for OOLua in Debug mode. VS didn't complain and the only issue I had was when getting the error with OOLUA::get_last_error.

    I'm sorry the cause of this issue was a silly mistake.

    Thanks for your time and pointing me in the right direction to solve this issue.

  4. Log in to comment