[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Bug in LuaJIT
- From: Venkat Murty <venkat_murty@...>
- Date: Tue, 29 Dec 2009 14:39:59 -0800 (PST)
/** The attached code prints out 202 lines with standard lua.
And 103 lines with LuaJIT. (LuaJIT-2.0.0-beta2)
*/
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static void
hook (lua_State* L, lua_Debug *ar)
{
lua_yield (L, 0);
}
int bug () {
char* lua = "function foo (x) for i = 1, 100, 1 do print (x) end end";
lua_State* L;
lua_State *L1 = NULL;
lua_State *L2 = NULL;
L = luaL_newstate ();
luaL_openlibs (L);
(void) (luaL_loadbuffer (L, lua, strlen(lua), "bug") || lua_pcall (L, 0, 0, 0));
L1 = lua_newthread (L);
L2 = lua_newthread (L);
lua_sethook (L, hook, LUA_MASKCOUNT, 10);
lua_sethook (L1, hook, LUA_MASKCOUNT, 10);
lua_getglobal (L1, "foo");
lua_pushstring (L1, "L1");
lua_sethook (L2, hook, LUA_MASKCOUNT, 10);
lua_getglobal (L2, "foo");
lua_pushstring (L2, "L2");
lua_resume (L1, 1);
lua_resume (L2, 1);
while (L1 || L2)
{
if (L1 && lua_resume (L1, 0) != LUA_YIELD) {
L1 = NULL;
fprintf (stdout, "Ending L1\n");
}
if (L2 && lua_resume (L2, 0) != LUA_YIELD) {
L2 = NULL;
fprintf (stdout, "Ending L2\n");
}
}
lua_close (L);
return 0;
}