Program: 43999
Project: 43999
Buggy source:
public boolean luaStackCall(LuaState vm){
switch (id) {
case PRINT:
{
      int n=vm.gettop();
      for (int i=2; i <= n; i++) {
        if (i > 2)         stdout.print("String_Node_Str");
        stdout.print(vm.tostring(i));
      }
      stdout.println();
      vm.resettop();
      break;
    }
case PAIRS:
case IPAIRS:
{
    checkargtype(vm,2,Lua.LUA_TTABLE);
    LTable v=vm.totable(2);
    LValue r=v.luaPairs(id == PAIRS);
    vm.resettop();
    vm.pushlvalue(r);
    break;
  }
case GETMETATABLE:
{
  checkargexists(vm,2,Lua.LUA_TVALUE);
  if (!vm.getmetatable(2)) {
    vm.resettop();
    vm.pushnil();
  }
 else {
    vm.insert(1);
    vm.settop(1);
  }
  break;
}
case SETMETATABLE:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
vm.setmetatable(2);
vm.remove(1);
break;
}
case TYPE:
{
if (vm.gettop() < 2) vm.error("String_Node_Str");
LValue v=vm.topointer(2);
vm.resettop();
vm.pushlstring(v.luaGetTypeName());
break;
}
case PCALL:
{
int n=vm.gettop();
int s=vm.pcall(n - 2,Lua.LUA_MULTRET,0);
if (s == 0) {
vm.remove(1);
vm.pushboolean(true);
vm.insert(1);
}
 else {
vm.pushboolean(false);
vm.insert(1);
}
break;
}
case ERROR:
{
vm.error(vm.tostring(2),vm.gettop() >= 3 ? vm.tointeger(3) : 1);
break;
}
case ASSERT:
{
if (!vm.toboolean(2)) vm.error(vm.gettop() > 2 ? vm.tostring(3) : "String_Node_Str",0);
vm.remove(1);
break;
}
case LOADFILE:
loadfile(vm,vm.tostring(2));
break;
case TONUMBER:
{
checkargexists(vm,2,Lua.LUA_TVALUE);
switch (vm.type(2)) {
case Lua.LUA_TNUMBER:
break;
case Lua.LUA_TSTRING:
LString s=vm.tolstring(2);
int base=10;
if (vm.isnumber(3)) {
base=vm.tolnumber(3).toJavaInt();
if (base < 2 || base > 36) vm.error("String_Node_Str");
}
vm.pushlvalue(s.luaToNumber(base));
break;
default :
vm.pushnil();
break;
}
vm.insert(1);
vm.settop(1);
break;
}
case RAWGET:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
checkargexists(vm,3,Lua.LUA_TVALUE);
LTable t=vm.totable(2);
LValue k=vm.topointer(3);
vm.resettop();
vm.pushlvalue(t.get(k));
}
break;
case RAWSET:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
checkargexists(vm,3,Lua.LUA_TVALUE);
checkargexists(vm,4,Lua.LUA_TVALUE);
LTable t=vm.totable(2);
LValue k=vm.topointer(3);
LValue v=vm.topointer(4);
t.put(k,v);
vm.resettop();
vm.pushlvalue(t);
}
break;
case GETFENV:
{
if (vm.isfunction(2)) {
vm.getfenv(-1);
}
 else {
int i=(vm.isnil(2) ? 1 : vm.tointeger(2));
if (i <= 0) vm.pushlvalue(vm._G);
 else if (i - 1 <= vm.cc) vm.pushlvalue(vm.getStackFrame(i - 1).closure.env);
 else vm.pushnil();
}
vm.insert(1);
vm.settop(1);
break;
}
case SETFENV:
{
LTable t=vm.totable(-1);
if (vm.setfenv(2) != 0) {
vm.remove(1);
break;
}
int i=vm.tointeger(2);
if (i == 0) {
vm._G=t;
vm.resettop();
}
 else {
LClosure c=vm.getStackFrame(i - 1).closure;
c.luaSetEnv(t);
vm.resettop();
vm.pushlvalue(c);
}
break;
}
case SELECT:
{
checkargexists(vm,2,Lua.LUA_TNUMBER);
int n=vm.gettop();
if (vm.isnumber(2)) {
int index=vm.tolnumber(2).toJavaInt();
if (index < 0) index+=n - 1;
if (index <= 0) vm.error("String_Node_Str");
if (index >= n) vm.resettop();
 else {
for (int i=0; i <= index; i++) vm.remove(1);
}
}
 else if (vm.tostring(2).equals("String_Node_Str")) {
vm.resettop();
vm.pushnumber(n - 2);
}
 else {
vm.error("String_Node_Str" + vm.typename(2) + "String_Node_Str");
}
break;
}
case COLLECTGARBAGE:
{
String s=vm.tostring(2);
int result=0;
vm.resettop();
if ("String_Node_Str".equals(s)) System.gc();
 else {
Runtime rt=Runtime.getRuntime();
long used=rt.totalMemory() - rt.freeMemory();
result=(int)(used >> 10);
}
vm.pushnumber(result);
break;
}
case DOFILE:
dofile(vm);
break;
case LOADSTRING:
loadstring(vm,vm.topointer(2),vm.tostring(3));
break;
case LOAD:
load(vm,vm.topointer(2),vm.tostring(3));
break;
case TOSTRING:
{
checkargexists(vm,2,Lua.LUA_TVALUE);
LValue v=vm.topointer(2);
vm.resettop();
vm.pushlvalue(v.luaAsString());
break;
}
case UNPACK:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
LTable list=vm.totable(2);
int n=vm.gettop();
int i=1, j;
if (n >= 3) {
checkargtype(vm,3,Lua.LUA_TNUMBER);
i=vm.tolnumber(3).toJavaInt();
}
if (n >= 4) {
checkargtype(vm,4,Lua.LUA_TNUMBER);
j=vm.tolnumber(4).toJavaInt();
}
 else {
j=list.luaLength();
}
vm.resettop();
vm.checkstack(j + 1 - i);
for (int k=i; k <= j; k++) vm.pushlvalue(list.get(k));
break;
}
case NEXT:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
LTable t=vm.totable(2);
LValue v=vm.topointer(3);
vm.resettop();
t.next(vm,v);
break;
}
default :
throw new RuntimeException("String_Node_Str" + id);
}
return false;
}

Fixed version (ground truth):
public boolean luaStackCall(LuaState vm){
switch (id) {
case PRINT:
{
      int n=vm.gettop();
      for (int i=2; i <= n; i++) {
        if (i > 2)         stdout.print("String_Node_Str");
        stdout.print(vm.tostring(i));
      }
      stdout.println();
      vm.resettop();
      break;
    }
case PAIRS:
case IPAIRS:
{
    checkargtype(vm,2,Lua.LUA_TTABLE);
    LTable v=vm.totable(2);
    LValue r=v.luaPairs(id == PAIRS);
    vm.resettop();
    vm.pushlvalue(r);
    break;
  }
case GETMETATABLE:
{
  checkargexists(vm,2,Lua.LUA_TVALUE);
  if (!vm.getmetatable(2)) {
    vm.resettop();
    vm.pushnil();
  }
 else {
    vm.insert(1);
    vm.settop(1);
  }
  break;
}
case SETMETATABLE:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
vm.setmetatable(2);
vm.remove(1);
break;
}
case TYPE:
{
if (vm.gettop() < 2) vm.error("String_Node_Str");
LValue v=vm.topointer(2);
vm.resettop();
vm.pushlstring(v.luaGetTypeName());
break;
}
case PCALL:
{
int n=vm.gettop();
int s=vm.pcall(n - 2,Lua.LUA_MULTRET,0);
if (s == 0) {
vm.remove(1);
vm.pushboolean(true);
vm.insert(1);
}
 else {
vm.pushboolean(false);
vm.insert(1);
}
break;
}
case ERROR:
{
vm.error(vm.tostring(2),vm.gettop() >= 3 ? vm.tointeger(3) : 1);
break;
}
case ASSERT:
{
if (!vm.toboolean(2)) vm.error(vm.gettop() > 2 ? vm.tostring(3) : "String_Node_Str",0);
vm.remove(1);
break;
}
case LOADFILE:
loadfile(vm,vm.tostring(2));
break;
case TONUMBER:
{
checkargexists(vm,2,Lua.LUA_TVALUE);
switch (vm.type(2)) {
case Lua.LUA_TNUMBER:
break;
case Lua.LUA_TSTRING:
LString s=vm.tolstring(2);
int base=10;
if (vm.isnumber(3)) {
base=vm.tolnumber(3).toJavaInt();
if (base < 2 || base > 36) vm.error("String_Node_Str");
}
vm.pushlvalue(s.luaToNumber(base));
break;
default :
vm.pushnil();
break;
}
vm.insert(1);
vm.settop(1);
break;
}
case RAWGET:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
checkargexists(vm,3,Lua.LUA_TVALUE);
LTable t=vm.totable(2);
LValue k=vm.topointer(3);
vm.resettop();
vm.pushlvalue(t.get(k));
}
break;
case RAWSET:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
checkargexists(vm,3,Lua.LUA_TVALUE);
checkargexists(vm,4,Lua.LUA_TVALUE);
LTable t=vm.totable(2);
LValue k=vm.topointer(3);
LValue v=vm.topointer(4);
t.put(k,v);
vm.resettop();
vm.pushlvalue(t);
}
break;
case GETFENV:
{
if (vm.isfunction(2)) {
vm.getfenv(-1);
}
 else {
int i=(vm.isnil(2) ? 1 : vm.tointeger(2));
if (i <= 0) vm.pushlvalue(vm._G);
 else if (i - 1 <= vm.cc) vm.pushlvalue(vm.getStackFrame(i - 1).closure.env);
 else vm.pushnil();
}
vm.insert(1);
vm.settop(1);
break;
}
case SETFENV:
{
LTable t=vm.totable(-1);
if (vm.setfenv(2) != 0) {
vm.remove(1);
break;
}
int i=vm.tointeger(2);
if (i == 0) {
vm._G=t;
vm.resettop();
}
 else {
LClosure c=vm.getStackFrame(i - 1).closure;
c.luaSetEnv(t);
vm.resettop();
vm.pushlvalue(c);
}
break;
}
case SELECT:
{
checkargexists(vm,2,Lua.LUA_TNUMBER);
int n=vm.gettop();
if (vm.isnumber(2)) {
int index=vm.tolnumber(2).toJavaInt();
if (index < 0) index+=n - 1;
if (index <= 0) vm.error("String_Node_Str");
if (index >= n) vm.resettop();
 else {
for (int i=0; i <= index; i++) vm.remove(1);
}
}
 else if (vm.tostring(2).equals("String_Node_Str")) {
vm.resettop();
vm.pushnumber(n - 2);
}
 else {
vm.error("String_Node_Str" + vm.typename(2) + "String_Node_Str");
}
break;
}
case COLLECTGARBAGE:
{
String s=vm.tostring(2);
int result=0;
vm.resettop();
if ("String_Node_Str".equals(s)) System.gc();
 else {
Runtime rt=Runtime.getRuntime();
long used=rt.totalMemory() - rt.freeMemory();
result=(int)(used >> 10);
}
vm.pushnumber(result);
break;
}
case DOFILE:
dofile(vm);
break;
case LOADSTRING:
loadstring(vm,vm.topointer(2),vm.tostring(3));
break;
case LOAD:
load(vm,vm.topointer(2),vm.tostring(3));
break;
case TOSTRING:
{
checkargexists(vm,2,Lua.LUA_TVALUE);
LValue v=vm.topointer(2);
vm.resettop();
vm.pushlvalue(v.luaAsString());
break;
}
case UNPACK:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
LTable list=vm.totable(2);
int n=vm.gettop();
int i=1, j;
if (n >= 3) {
checkargtype(vm,3,Lua.LUA_TNUMBER);
i=vm.tolnumber(3).toJavaInt();
}
if (n >= 4) {
checkargtype(vm,4,Lua.LUA_TNUMBER);
j=vm.tolnumber(4).toJavaInt();
}
 else {
j=list.luaLength();
}
vm.resettop();
vm.checkstack(j + 1 - i);
for (int k=i; k <= j; k++) vm.pushlvalue(list.get(k));
break;
}
case NEXT:
{
checkargtype(vm,2,Lua.LUA_TTABLE);
LTable t=vm.totable(2);
LValue v=vm.topointer(3);
vm.resettop();
t.next(vm,v);
break;
}
default :
LuaState.vmerror("String_Node_Str");
}
return false;
}