开发者

lua_getglobal crashing program

I made a previous post regarding trying to call lua functions from C. You can take a look at that here:

Lua: getting global function failing after loading file

As you can see, I am loading the lua file and then attempting to get the function and call it. One reader suggested my solution to that problem was to change to dofile rather than load file because you need to execute the script to access those functions. But that's not the problem at hand...

Regardless of using dofile or loadfile, When I call the lua_getglobal(L, "abc");

my program crashes...

Callstack:

>   Translation.exe!luaS_newlstr(lua_State * L=0xcccccccc, const char * str=0x00460924, unsigned int l=3)  Line 84 + 0x3 bytes  C
    Translation.exe!lua_getfield(lua_State * L=0xcccccccc, int idx=-10002, const char * k=0x0046开发者_JAVA技巧0924)  Line 551 + 0x20 bytes    C
    Translation.exe!LanguageShovel::FileFound(std::basic_string<char,std::char_traits<char>,std::allocator<char> > path="C:\Loud\Resolution\orchid\source\EAWResolutionApplication.cpp")  Line 32 + 0x16 bytes  C++

Crashes on:

  for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
       o != NULL;
       o = o->gch.next) {

in the lstring.c file in Lua library. I have no idea what the heck is going on in this lua source code. Do you think it could be a lua bug? Or am I just doing this incorrectly?

Running: Windows xp 32 bit.


The L=0xcccccccc suggests that you didn't pass the Lua state variable correctly to this function (or that it was lost somewhere between your lua_open and lua_getglobal calls).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜