You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by Andrew Huntwork <as...@huntwork.net> on 2003/07/22 01:12:24 UTC

bug in InstructionList: shouldn't dispose Instruction's on delete

I'm ending up with an InstructionList that contains a goto Instruction
whose target is null, and the reason for that is the call to dispose()
on line 737 of InstructionList.java.  I believe lines 736 and 737 should
just be removed.  An Instruction can be the instruction for multiple
handles, so deleting one should not invalidate the instruction of the
other handles.  I can provide sample code to demonstrate what i'm
talking about, but I think it would go something like this:

InstructionList il = new InstructionList();
InstructionHandle nop = il.append(new NOP());
InstructionHandle goto1 = il.append(new GOTO(nop));
InstructionHandle goto2 = il.append(new GOTO(nop));
il.delete(goto2);
if(((GOTO)goto1.getInstruction()).getTarget() == null)
   panic("It really should be nop");

-- 
"I say to you that the VCR is to the American film
producer and the American public as the Boston
strangler is to the woman home alone."
         -Jack Valenti, President, Motion Picture
          Association of America, Inc., before
          The House Subcommittee on Courts, Civil
          Liberties, and The Administration of
          Justice, August, 1982,
          http://cryptome.org/hrcw-hear.htm



---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org


Re: bug in InstructionList: shouldn't dispose Instruction's on delete

Posted by Andrew Huntwork <as...@huntwork.net>.
whoops, that's really not the right test case.  Here's the real thing:

InstructionList il = new InstructionList();
InstructionHandle nop = il.append(new NOP());
GOTO g = new GOTO(nop);
il.append(g);
il.delete(il.append(g));
if(g.getTarget() == null)
    panic();

Andrew Huntwork wrote:
> I'm ending up with an InstructionList that contains a goto Instruction
> whose target is null, and the reason for that is the call to dispose()
> on line 737 of InstructionList.java.  I believe lines 736 and 737 should
> just be removed.  An Instruction can be the instruction for multiple
> handles, so deleting one should not invalidate the instruction of the
> other handles.  I can provide sample code to demonstrate what i'm
> talking about, but I think it would go something like this:
> 
> InstructionList il = new InstructionList();
> InstructionHandle nop = il.append(new NOP());
> InstructionHandle goto1 = il.append(new GOTO(nop));
> InstructionHandle goto2 = il.append(new GOTO(nop));
> il.delete(goto2);
> if(((GOTO)goto1.getInstruction()).getTarget() == null)
>   panic("It really should be nop");
> 

-- 
"I say to you that the VCR is to the American film
producer and the American public as the Boston
strangler is to the woman home alone."
         -Jack Valenti, President, Motion Picture
          Association of America, Inc., before
          The House Subcommittee on Courts, Civil
          Liberties, and The Administration of
          Justice, August, 1982,
          http://cryptome.org/hrcw-hear.htm


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org