Program: 44040
Project: 44040
Buggy source:
public void exec(){
  int i, a, b, c, o, n, cb;
  LValue rkb, rkc, nvarargs, key, val;
  StringBuffer sb;
  LValue i0, step, idx, limit, init, table;
  boolean back, body;
  Proto proto;
  Closure newClosure;
  int[] code=p.code;
  while (true) {
    if (DEBUG)     Print.printState(state,base,top,state.avail,cl,pc);
    i=code[pc++];
    a=StackState.GETARG_A(i);
switch (StackState.GET_OPCODE(i)) {
case StackState.OP_MOVE:
{
        b=StackState.GETARG_B(i);
        this.stack[base + a]=this.stack[base + b];
        continue;
      }
case StackState.OP_LOADK:
{
      b=StackState.GETARG_Bx(i);
      this.stack[base + a]=k[b];
      continue;
    }
case StackState.OP_LOADBOOL:
{
    b=StackState.GETARG_B(i);
    c=StackState.GETARG_C(i);
    this.stack[base + a]=(b != 0 ? LBoolean.TRUE : LBoolean.FALSE);
    if (c != 0)     pc++;
    continue;
  }
case StackState.OP_LOADNIL:
{
  b=StackState.GETARG_B(i);
  do {
    this.stack[base + b]=LNil.NIL;
  }
 while ((--b) >= a);
  continue;
}
case StackState.OP_GETUPVAL:
{
b=StackState.GETARG_B(i);
this.stack[base + a]=cl.upVals[b].getValue();
continue;
}
case StackState.OP_GETGLOBAL:
{
b=StackState.GETARG_Bx(i);
key=k[b];
table=cl.env;
table.luaGetTable(this,base + a,table,key);
continue;
}
case StackState.OP_GETTABLE:
{
b=StackState.GETARG_B(i);
key=GETARG_RKC(i);
table=this.stack[base + b];
table.luaGetTable(this,base + a,table,key);
continue;
}
case StackState.OP_SETGLOBAL:
{
b=StackState.GETARG_Bx(i);
key=k[b];
val=this.stack[base + a];
table=cl.env;
table.luaSetTable(this,this.state.avail,table,key,val);
continue;
}
case StackState.OP_SETUPVAL:
{
b=StackState.GETARG_B(i);
cl.upVals[b].setValue(this.stack[base + a]);
continue;
}
case StackState.OP_SETTABLE:
{
key=GETARG_RKB(i);
val=GETARG_RKC(i);
table=this.stack[base + a];
table.luaSetTable(this,state.avail,table,key,val);
continue;
}
case StackState.OP_NEWTABLE:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
this.stack[base + a]=new LTable(b,c);
continue;
}
case StackState.OP_SELF:
{
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
this.stack[base + a + 1]=rkb;
rkb.luaGetTable(this,base + a,rkb,rkc);
continue;
}
case StackState.OP_ADD:
case StackState.OP_SUB:
case StackState.OP_MUL:
case StackState.OP_DIV:
case StackState.OP_MOD:
case StackState.OP_POW:
{
o=StackState.GET_OPCODE(i);
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
this.stack[base + a]=rkc.luaBinOpUnknown(o,rkb);
continue;
}
case StackState.OP_UNM:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=rkb.luaUnaryMinus();
continue;
}
case StackState.OP_NOT:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=(rkb.luaAsBoolean() ? LBoolean.TRUE : LBoolean.FALSE);
continue;
}
case StackState.OP_LEN:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=rkb.luaLength();
continue;
}
case StackState.OP_CONCAT:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
sb=new StringBuffer();
for (int j=b; j <= c; j++) sb.append(this.stack[base + j].luaAsString());
this.stack[base + a]=new LString(sb.toString());
continue;
}
case StackState.OP_JMP:
{
pc+=StackState.GETARG_sBx(i);
continue;
}
case StackState.OP_EQ:
case StackState.OP_LT:
case StackState.OP_LE:
{
o=StackState.GET_OPCODE(i);
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
boolean test=rkc.luaBinCmpUnknown(o,rkb);
if (test) pc++;
continue;
}
case StackState.OP_TEST:
{
c=StackState.GETARG_C(i);
if (this.stack[base + a].luaAsBoolean() != (c != 0)) pc++;
continue;
}
case StackState.OP_TESTSET:
{
rkb=GETARG_RKB(i);
c=StackState.GETARG_C(i);
if (rkb.luaAsBoolean() != (c != 0)) pc++;
 else this.stack[base + a]=rkb;
continue;
}
case StackState.OP_CALL:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
if (b != 0) top=base + a + b;
this.stack[base + a].luaStackCall(this,base + a,top,c - 1);
if (this.state.calls[this.state.cc] != this) return;
if (c > 0) adjustTop(base + a + c - 1);
continue;
}
case StackState.OP_TAILCALL:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
if (b != 0) top=base + a + b;
close(base);
this.stack[base + a].luaStackCall(this,base + a,top,c - 1);
if (this.state.calls[this.state.cc] != this) {
CallFrame ci=this.state.calls[this.state.cc];
n=ci.top - ci.base;
System.arraycopy(this.stack,ci.base,this.stack,base,n);
ci.base=base;
ci.top=base + n;
this.state.calls[this.state.cc - 1]=this.state.calls[this.state.cc];
--this.state.cc;
return;
}
continue;
}
case StackState.OP_RETURN:
{
b=StackState.GETARG_B(i);
if (b != 0) top=base + a + b - 1;
close(base);
n=top - (base + a);
System.arraycopy(this.stack,base + a,this.stack,base - 1,n);
top=base - 1 + n;
if (nresults >= 0) adjustTop(base + nresults);
done=true;
if (--state.cc >= 0) {
CallFrame call=state.calls[state.cc];
call.top=top;
}
return;
}
case StackState.OP_FORLOOP:
{
i0=this.stack[base + a];
step=this.stack[base + a + 2];
idx=step.luaBinOpUnknown(Lua.OP_ADD,i0);
limit=this.stack[base + a + 1];
back=step.luaBinCmpInteger(Lua.OP_LT,0);
body=(back ? idx.luaBinCmpUnknown(Lua.OP_LE,limit) : limit.luaBinCmpUnknown(Lua.OP_LE,idx));
if (body) {
this.stack[base + a]=idx;
this.stack[base + a + 3]=idx;
pc+=StackState.GETARG_sBx(i);
}
continue;
}
case StackState.OP_FORPREP:
{
init=this.stack[base + a];
step=this.stack[base + a + 2];
this.stack[base + a]=step.luaBinOpUnknown(Lua.OP_SUB,init);
b=StackState.GETARG_sBx(i);
pc+=b;
continue;
}
case StackState.OP_TFORLOOP:
{
cb=a + 3;
System.arraycopy(this.stack,base + a,this.stack,base + cb,3);
top=base + cb + 3;
c=StackState.GETARG_C(i);
this.stack[base + a].luaStackCall(this,base + cb,top,c - 1);
if (this.stack[base + cb] != LNil.NIL) {
this.stack[base + cb - 1]=this.stack[base + cb];
}
 else {
pc++;
}
continue;
}
case StackState.OP_SETLIST:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
if (b == 0) {
b=top - 1;
}
if (c == 0) {
c=code[pc++];
}
table=this.stack[base + a];
for (int index=1; index <= b; index++) {
val=this.stack[base + a + index];
table.luaSetTable(this,this.state.avail,table,new LInteger(index),val);
}
top=base + a - 1;
continue;
}
case StackState.OP_CLOSE:
{
close(a);
continue;
}
case StackState.OP_CLOSURE:
{
b=StackState.GETARG_Bx(i);
proto=cl.p.p[b];
newClosure=new Closure(this.state,proto);
for (int j=0; j < newClosure.upVals.length; j++, pc++) {
i=code[pc];
o=StackState.GET_OPCODE(i);
b=StackState.GETARG_B(i);
if (o == StackState.OP_GETUPVAL) {
newClosure.upVals[j]=cl.upVals[b];
}
 else if (o == StackState.OP_MOVE) {
newClosure.upVals[j]=findUpVal(proto.upvalues[j],base + b);
}
 else {
throw new java.lang.IllegalArgumentException("String_Node_Str" + o);
}
}
this.stack[base + a]=newClosure;
continue;
}
case StackState.OP_VARARG:
{
b=StackState.GETARG_B(i) - 1;
nvarargs=this.stack[base - 1];
n=nvarargs.luaAsInt();
if (b == StackState.LUA_MULTRET) {
b=n;
}
for (int j=0; j < b; j++) this.stack[base + a + j]=(j < n ? this.stack[base - n + j - 1] : LNil.NIL);
top=base + a + b;
continue;
}
}
}
}

Fixed version (ground truth):
public void exec(){
  int i, a, b, c, o, n, cb;
  LValue rkb, rkc, nvarargs, key, val;
  StringBuffer sb;
  LValue i0, step, idx, limit, init, table;
  boolean back, body;
  Proto proto;
  Closure newClosure;
  int[] code=p.code;
  while (true) {
    if (DEBUG)     Print.printState(state,base,top,state.avail,cl,pc);
    i=code[pc++];
    a=StackState.GETARG_A(i);
switch (StackState.GET_OPCODE(i)) {
case StackState.OP_MOVE:
{
        b=StackState.GETARG_B(i);
        this.stack[base + a]=this.stack[base + b];
        continue;
      }
case StackState.OP_LOADK:
{
      b=StackState.GETARG_Bx(i);
      this.stack[base + a]=k[b];
      continue;
    }
case StackState.OP_LOADBOOL:
{
    b=StackState.GETARG_B(i);
    c=StackState.GETARG_C(i);
    this.stack[base + a]=(b != 0 ? LBoolean.TRUE : LBoolean.FALSE);
    if (c != 0)     pc++;
    continue;
  }
case StackState.OP_LOADNIL:
{
  b=StackState.GETARG_B(i);
  do {
    this.stack[base + b]=LNil.NIL;
  }
 while ((--b) >= a);
  continue;
}
case StackState.OP_GETUPVAL:
{
b=StackState.GETARG_B(i);
this.stack[base + a]=cl.upVals[b].getValue();
continue;
}
case StackState.OP_GETGLOBAL:
{
b=StackState.GETARG_Bx(i);
key=k[b];
table=cl.env;
table.luaGetTable(this,base + a,table,key);
continue;
}
case StackState.OP_GETTABLE:
{
b=StackState.GETARG_B(i);
key=GETARG_RKC(i);
table=this.stack[base + b];
table.luaGetTable(this,base + a,table,key);
continue;
}
case StackState.OP_SETGLOBAL:
{
b=StackState.GETARG_Bx(i);
key=k[b];
val=this.stack[base + a];
table=cl.env;
table.luaSetTable(this,this.state.avail,table,key,val);
continue;
}
case StackState.OP_SETUPVAL:
{
b=StackState.GETARG_B(i);
cl.upVals[b].setValue(this.stack[base + a]);
continue;
}
case StackState.OP_SETTABLE:
{
key=GETARG_RKB(i);
val=GETARG_RKC(i);
table=this.stack[base + a];
table.luaSetTable(this,state.avail,table,key,val);
continue;
}
case StackState.OP_NEWTABLE:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
this.stack[base + a]=new LTable(b,c);
continue;
}
case StackState.OP_SELF:
{
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
this.stack[base + a + 1]=rkb;
rkb.luaGetTable(this,base + a,rkb,rkc);
continue;
}
case StackState.OP_ADD:
case StackState.OP_SUB:
case StackState.OP_MUL:
case StackState.OP_DIV:
case StackState.OP_MOD:
case StackState.OP_POW:
{
o=StackState.GET_OPCODE(i);
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
this.stack[base + a]=rkc.luaBinOpUnknown(o,rkb);
continue;
}
case StackState.OP_UNM:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=rkb.luaUnaryMinus();
continue;
}
case StackState.OP_NOT:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=(rkb.luaAsBoolean() ? LBoolean.TRUE : LBoolean.FALSE);
continue;
}
case StackState.OP_LEN:
{
rkb=GETARG_RKB(i);
this.stack[base + a]=rkb.luaLength();
continue;
}
case StackState.OP_CONCAT:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
sb=new StringBuffer();
for (int j=b; j <= c; j++) sb.append(this.stack[base + j].luaAsString());
this.stack[base + a]=new LString(sb.toString());
continue;
}
case StackState.OP_JMP:
{
pc+=StackState.GETARG_sBx(i);
continue;
}
case StackState.OP_EQ:
case StackState.OP_LT:
case StackState.OP_LE:
{
o=StackState.GET_OPCODE(i);
rkb=GETARG_RKB(i);
rkc=GETARG_RKC(i);
boolean test=rkc.luaBinCmpUnknown(o,rkb);
if (test) pc++;
continue;
}
case StackState.OP_TEST:
{
c=StackState.GETARG_C(i);
if (this.stack[base + a].luaAsBoolean() != (c != 0)) pc++;
continue;
}
case StackState.OP_TESTSET:
{
rkb=GETARG_RKB(i);
c=StackState.GETARG_C(i);
if (rkb.luaAsBoolean() != (c != 0)) pc++;
 else this.stack[base + a]=rkb;
continue;
}
case StackState.OP_CALL:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
if (b != 0) top=base + a + b;
this.stack[base + a].luaStackCall(this,base + a,top,c - 1);
if (this.state.calls[this.state.cc] != this) return;
if (c > 0) adjustTop(base + a + c - 1);
continue;
}
case StackState.OP_TAILCALL:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
if (b != 0) top=base + a + b;
close(base);
this.stack[base + a].luaStackCall(this,base + a,top,c - 1);
if (this.state.calls[this.state.cc] != this) {
CallFrame ci=this.state.calls[this.state.cc];
n=ci.top - ci.base;
System.arraycopy(this.stack,ci.base,this.stack,base,n);
ci.base=base;
ci.top=base + n;
this.state.calls[this.state.cc - 1]=this.state.calls[this.state.cc];
--this.state.cc;
return;
}
continue;
}
case StackState.OP_RETURN:
{
b=StackState.GETARG_B(i);
if (b != 0) top=base + a + b - 1;
close(base);
n=top - (base + a);
System.arraycopy(this.stack,base + a,this.stack,base - 1,n);
top=base - 1 + n;
if (nresults >= 0) adjustTop(base + nresults);
done=true;
if (--state.cc >= 0) {
CallFrame call=state.calls[state.cc];
call.top=top;
}
return;
}
case StackState.OP_FORLOOP:
{
i0=this.stack[base + a];
step=this.stack[base + a + 2];
idx=step.luaBinOpUnknown(Lua.OP_ADD,i0);
limit=this.stack[base + a + 1];
back=step.luaBinCmpInteger(Lua.OP_LT,0);
body=(back ? idx.luaBinCmpUnknown(Lua.OP_LE,limit) : limit.luaBinCmpUnknown(Lua.OP_LE,idx));
if (body) {
this.stack[base + a]=idx;
this.stack[base + a + 3]=idx;
pc+=StackState.GETARG_sBx(i);
}
continue;
}
case StackState.OP_FORPREP:
{
init=this.stack[base + a];
step=this.stack[base + a + 2];
this.stack[base + a]=step.luaBinOpUnknown(Lua.OP_SUB,init);
b=StackState.GETARG_sBx(i);
pc+=b;
continue;
}
case StackState.OP_TFORLOOP:
{
cb=a + 3;
System.arraycopy(this.stack,base + a,this.stack,base + cb,3);
top=base + cb + 3;
c=StackState.GETARG_C(i);
this.stack[base + a].luaStackCall(this,base + cb,top,c - 1);
if (this.stack[base + cb] != LNil.NIL) {
this.stack[base + cb - 1]=this.stack[base + cb];
}
 else {
pc++;
}
continue;
}
case StackState.OP_SETLIST:
{
b=StackState.GETARG_B(i);
c=StackState.GETARG_C(i);
int listBase=base + a;
if (b == 0) {
b=top - listBase - 1;
}
if (c == 0) {
c=code[pc++];
}
table=this.stack[base + a];
for (int index=1; index <= b; index++) {
val=this.stack[listBase + index];
table.luaSetTable(this,this.state.avail,table,new LInteger(index),val);
}
top=base + a - 1;
continue;
}
case StackState.OP_CLOSE:
{
close(a);
continue;
}
case StackState.OP_CLOSURE:
{
b=StackState.GETARG_Bx(i);
proto=cl.p.p[b];
newClosure=new Closure(this.state,proto);
for (int j=0; j < newClosure.upVals.length; j++, pc++) {
i=code[pc];
o=StackState.GET_OPCODE(i);
b=StackState.GETARG_B(i);
if (o == StackState.OP_GETUPVAL) {
newClosure.upVals[j]=cl.upVals[b];
}
 else if (o == StackState.OP_MOVE) {
newClosure.upVals[j]=findUpVal(proto.upvalues[j],base + b);
}
 else {
throw new java.lang.IllegalArgumentException("String_Node_Str" + o);
}
}
this.stack[base + a]=newClosure;
continue;
}
case StackState.OP_VARARG:
{
b=StackState.GETARG_B(i) - 1;
nvarargs=this.stack[base - 1];
n=nvarargs.luaAsInt();
if (b == StackState.LUA_MULTRET) {
b=n;
}
for (int j=0; j < b; j++) this.stack[base + a + j]=(j < n ? this.stack[base - n + j - 1] : LNil.NIL);
top=base + a + b;
continue;
}
}
}
}