Program: 45379
Project: 45379
Buggy source:
byte[] emitAbc(Abc abc) throws IOException {
  AbcWriter w=new AbcWriter();
  w.writeU16(16);
  w.writeU16(46);
  int pos=w.size();
  w.writeU30(abc.intPool.size());
  for (  int x : abc.intPool.values)   w.writeU30(x);
  verboseStatus("String_Node_Str" + abc.intPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.uintPool.size());
  for (  long x : abc.uintPool.values)   w.writeU30((int)x);
  verboseStatus("String_Node_Str" + abc.uintPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  verboseStatus("String_Node_Str" + abc.doublePool.size());
  w.writeU30(abc.doublePool.size());
  for (  double x : abc.doublePool.values)   w.write64(Double.doubleToLongBits(x));
  verboseStatus("String_Node_Str" + abc.doublePool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.stringPool.size());
  for (  String s : abc.stringPool.values) {
    w.writeU30(s.length());
    w.write(s.getBytes("String_Node_Str"));
  }
  verboseStatus("String_Node_Str" + abc.stringPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.nsPool.size());
  for (  Namespace ns : abc.nsPool.values)   emitNamespace(abc,w,ns);
  verboseStatus("String_Node_Str" + abc.nsPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.nssetPool.size());
  for (  Nsset nsset : abc.nssetPool.values) {
    w.writeU30(nsset.length);
    for (    Namespace ns : nsset)     w.writeU30(abc.nsPool.id(ns));
  }
  verboseStatus("String_Node_Str" + abc.nssetPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.namePool.size());
  for (  Name n : abc.namePool.values) {
    w.write(n.kind);
switch (n.kind) {
case CONSTANT_TypeName:
      throw new RuntimeException("String_Node_Str");
case CONSTANT_Qname:
case CONSTANT_QnameA:
    w.writeU30(abc.nsPool.id(n.nsset(0)));
  w.writeU30(abc.stringPool.id(n.name));
break;
case CONSTANT_Multiname:
case CONSTANT_MultinameA:
w.writeU30(abc.stringPool.id(n.name));
w.writeU30(abc.nssetPool.id(n.nsset));
break;
case CONSTANT_RTQname:
case CONSTANT_RTQnameA:
w.writeU30(abc.stringPool.id(n.name));
break;
case CONSTANT_MultinameL:
case CONSTANT_MultinameLA:
w.writeU30(abc.nssetPool.id(n.nsset));
break;
case CONSTANT_RTQnameL:
case CONSTANT_RTQnameLA:
break;
default :
assert(false);
}
}
verboseStatus("String_Node_Str" + abc.namePool.size() + "String_Node_Str"+ (w.size() - pos));
pos=w.size();
w.writeU30(abc.methodPool2.size());
int method_id=0;
for (Method m : abc.methodPool1.values) emitMethod(abc,w,method_id++,m);
for (Method m : abc.methodPool2.values) emitMethod(abc,w,method_id++,m);
w.writeU30(abc.metaPool.size());
for (Metadata md : abc.metaPool.values) {
w.writeU30(abc.stringPool.id(md.name));
w.writeU30(md.attrs.length);
for (Attr a : md.attrs) w.writeU30(abc.stringPool.id(a.name));
for (Attr a : md.attrs) w.writeU30(abc.stringPool.id(a.value));
}
w.writeU30(abc.classes.size());
for (Type c : abc.classes) {
Type t=c.itype;
w.writeU30(abc.namePool.id(t.name));
w.writeU30(abc.typeRef(t.base));
w.write(t.flags);
if (t.hasProtectedNs()) w.writeU30(abc.nsPool.id(t.protectedNs));
w.writeU30(t.interfaces.length);
for (Type i : t.interfaces) w.writeU30(abc.typeRef(i));
w.writeU30(abc.methodId(t.init));
emitTraits(w,abc,t);
}
for (Type c : abc.classes) {
w.writeU30(abc.methodId(c.init));
emitTraits(w,abc,c);
}
w.writeU30(abc.scripts.size());
for (Type s : abc.scripts) {
w.writeU30(abc.methodId(s.init));
emitTraits(w,abc,s);
}
w.writeU30(abc.bodyCount);
emitBodies(abc,w,abc.methodPool1);
emitBodies(abc,w,abc.methodPool2);
return w.toByteArray();
}

Fixed version (ground truth):
byte[] emitAbc(Abc abc) throws IOException {
  AbcWriter w=new AbcWriter();
  w.writeU16(16);
  w.writeU16(46);
  int pos=w.size();
  w.writeU30(abc.intPool.size());
  for (  int x : abc.intPool.values)   w.writeU30(x);
  verboseStatus("String_Node_Str" + abc.intPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.uintPool.size());
  for (  long x : abc.uintPool.values)   w.writeU30((int)x);
  verboseStatus("String_Node_Str" + abc.uintPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  verboseStatus("String_Node_Str" + abc.doublePool.size());
  w.writeU30(abc.doublePool.size());
  for (  double x : abc.doublePool.values)   w.write64(Double.doubleToLongBits(x));
  verboseStatus("String_Node_Str" + abc.doublePool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.stringPool.size());
  for (  String s : abc.stringPool.values) {
    w.writeU30(s.length());
    w.write(s.getBytes("String_Node_Str"));
  }
  verboseStatus("String_Node_Str" + abc.stringPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.nsPool.size());
  for (  Namespace ns : abc.nsPool.values)   emitNamespace(abc,w,ns);
  verboseStatus("String_Node_Str" + abc.nsPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.nssetPool.size());
  for (  Nsset nsset : abc.nssetPool.values) {
    w.writeU30(nsset.length);
    for (    Namespace ns : nsset)     w.writeU30(abc.nsPool.id(ns));
  }
  verboseStatus("String_Node_Str" + abc.nssetPool.size() + "String_Node_Str"+ (w.size() - pos));
  pos=w.size();
  w.writeU30(abc.namePool.size());
  for (  Name n : abc.namePool.values) {
    w.write(n.kind);
switch (n.kind) {
case CONSTANT_TypeName:
      throw new IllegalArgumentException("String_Node_Str");
case CONSTANT_Qname:
case CONSTANT_QnameA:
    w.writeU30(abc.nsPool.id(n.nsset(0)));
  w.writeU30(abc.stringPool.id(n.name));
break;
case CONSTANT_Multiname:
case CONSTANT_MultinameA:
w.writeU30(abc.stringPool.id(n.name));
w.writeU30(abc.nssetPool.id(n.nsset));
break;
case CONSTANT_RTQname:
case CONSTANT_RTQnameA:
w.writeU30(abc.stringPool.id(n.name));
break;
case CONSTANT_MultinameL:
case CONSTANT_MultinameLA:
w.writeU30(abc.nssetPool.id(n.nsset));
break;
case CONSTANT_RTQnameL:
case CONSTANT_RTQnameLA:
break;
default :
assert(false);
}
}
verboseStatus("String_Node_Str" + abc.namePool.size() + "String_Node_Str"+ (w.size() - pos));
pos=w.size();
w.writeU30(abc.methodPool2.size());
int method_id=0;
for (Method m : abc.methodPool1.values) emitMethod(abc,w,method_id++,m);
for (Method m : abc.methodPool2.values) emitMethod(abc,w,method_id++,m);
w.writeU30(abc.metaPool.size());
for (Metadata md : abc.metaPool.values) {
w.writeU30(abc.stringPool.id(md.name));
w.writeU30(md.attrs.length);
for (Attr a : md.attrs) w.writeU30(abc.stringPool.id(a.name));
for (Attr a : md.attrs) w.writeU30(abc.stringPool.id(a.value));
}
w.writeU30(abc.classes.size());
for (Type c : abc.classes) {
Type t=c.itype;
w.writeU30(abc.namePool.id(t.name));
w.writeU30(abc.typeRef(t.base));
w.write(t.flags);
if (t.hasProtectedNs()) w.writeU30(abc.nsPool.id(t.protectedNs));
w.writeU30(t.interfaces.length);
for (Type i : t.interfaces) w.writeU30(abc.typeRef(i));
w.writeU30(abc.methodId(t.init));
emitTraits(w,abc,t);
}
for (Type c : abc.classes) {
w.writeU30(abc.methodId(c.init));
emitTraits(w,abc,c);
}
w.writeU30(abc.scripts.size());
for (Type s : abc.scripts) {
w.writeU30(abc.methodId(s.init));
emitTraits(w,abc,s);
}
w.writeU30(abc.bodyCount);
emitBodies(abc,w,abc.methodPool1);
emitBodies(abc,w,abc.methodPool2);
return w.toByteArray();
}