Bug 4894

Summary: "java.lang.RuntimeException: not added" when removing codeObserver inside its own handler
Product: frysk Reporter: Petr Machata <pmachata>
Component: generalAssignee: Unassigned <frysk-bugzilla>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 2229    

Description Petr Machata 2007-08-03 22:22:50 UTC

The exception I'm getting is the following:
java.lang.RuntimeException: not added
   at frysk.proc.live.LinuxProcState$3.handleDeleteObservation(fltrace)
   at frysk.proc.Proc$13.execute(fltrace)
   at frysk.event.EventLoop.runEventLoop(fltrace)
   at frysk.event.EventLoop.run(fltrace)
   at frysk.util.Ltrace.trace(fltrace)
   at frysk.bindir.fltrace.run(fltrace)
   at frysk.bindir.fltrace.main(fltrace)

This happens when I have the following code in updateHit:
    public Action updateHit (Task task, long addr)
      task.requestDeleteCodeObserver(this, addr);
      return Action.BLOCK;

I created a test case, will commit that.
Comment 1 Petr Machata 2007-08-03 23:34:46 UTC
The test is testCodeRemovedInHit(frysk.proc.TestTaskObserverCode).

Btw, addFailed gets called even for failed delete request.  It's a bit confusing.
Comment 2 Mark Wielaard 2007-08-06 13:18:32 UTC
Thanks for the testcase. Code observers can be added multiple times for
different addresses (as you do in this test case). But Proc doesn't know about
this and treats the double add and one delete as if the Code observer should be
deleted completely, so if you delete it for the other address the Proc sanity
check kicks in and flags it as a double delete.

Quick workaround for now is to create different Code observers for different
Comment 3 Mark Wielaard 2007-08-06 14:44:51 UTC
2007-08-06  Mark Wielaard  <mark@klomp.org>

    Fixes bug #4894
    * Proc.java (observations): Turn into a Collection that can
    contain an observer multiple times.
    * TestTaskObserverCode.java (testCodeRemovedInHit): Explicitly
    wait for add and delete.