lua_getglobal崩溃程序 [英] lua_getglobal crashing program

查看:495
本文介绍了lua_getglobal崩溃程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



stackoverflow.com/questions/6741050/lua-getting-global-function-failing-after-loading-file\"> Lua:加载文件后全局函数失败



正如你可以看到,我正在加载lua文件,然后尝试获取该函数并调用它。一个读者建议我的解决方案的问题是更改为dofile而不是加载文件,因为您需要执行脚本来访问这些功能。但是这不是手头的问题...



无论使用dofile还是loadfile,当我调用lua_getglobal(L,abc);

我的程序崩溃...



Callstack:

  ; Translation.exe!luaS_newlstr(lua_State * L = 0xcccccccc,const char * str = 0x00460924,unsigned int l = 3)行84 + 0x3字节C 
Translation.exe!lua_getfield(lua_State * L = 0xcccccccc,int idx = -10002,const char * k = 0x00460924)行551 + 0x20字节C
Translation.exe!LanguageShovel :: FileFound(std :: basic_string< char,std :: char_traits< char>,std :: allocator< char> ;> path =C:\Loud\Resolution \orchid\source\EAWResolutionApplication.cpp)第32 + 0x16字节C ++

崩溃:

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

。我不知道在这个lua源代码中发生了什么。你认为它可能是一个lua bug吗?

解决方案



div>

L = 0xcccccccc 表明你没有正确地将Lua状态变量传递给这个函数(或者它在你的 lua_open lua_getglobal 调用)。


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=0x00460924)  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).

这篇关于lua_getglobal崩溃程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆