lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Have a look at linit.c in 5.1 and luaL_openlibs. You need to
do open the io library this way to avoid the segfault.

DB

On 11/12/05, Henderson, Michael D <michael.d.henderson@lmco.com> wrote:
>
>
> I downloaded and installed lua-5.1-beta-rc.tar.gz. When I try to open up the
> io library using "luaopen_io(L)" the application has a segmentation fault.
> The application does not seg fault when linked with 5.0.2.
>
> The line that seems to be causing the error is in src/liolib.c:
>   lua_replace(L, LUA_ENVIRONINDEX);
>
> My main.c contains:
> kbox: expected PASS found 139
>     lua_State *L = lua_open();
>     if (!L) {
>       fprintf(stdout, "error:\tunable to initialize Lua VM\n");
>       exit(2);
>     } else if (!luaopen_base(L)) {             // opens the basic library
>       fprintf(stdout, "error:\tunable to initialize Lua base library\n");
>       exit(2);
>     } else if (!luaopen_table(L)) {            // opens the table library
>       fprintf(stdout, "error:\tunable to initialize Lua table library\n");
>       exit(2);
>     } else if (!luaopen_io(L)) {               // opens the I/O library
>       fprintf(stdout, "error:\tunable to initialize Lua io library\n");
>       exit(2);
>     } else if (!luaopen_string(L)) {           // opens the string lib
>       fprintf(stdout, "error:\tunable to initialize Lua string library\n");
>       exit(2);
>     }
>
> I'm using gcc 4.0.0 on SunOS 5.8.
>
> Thanks,
> Mike
>
> .i le temci cu denpa no lo prenu
>         - Jessica Shewell Brockway