Bug 4401

Summary: Stepping Engine backtraces when Source Window is empty
Product: frysk Reporter: Rick Moseley <rmoseley>
Component: generalAssignee: Mike Cvet <mcvet>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 1633, 4193    

Description Rick Moseley 2007-04-21 04:42:06 UTC
I can get the frysk.rt.SteppingEngine to backtrace with these steps:

1. Bring up a SW with it pointing to a running bash shell with the "Quick Debug"
button.
2. Click on the "run" icon and then go exit the bash shell you were pointing at.
   (The source window title over the source frame should say "All processes have 
    exited" and no processes are showing in the entire SW.
3. Under the "File" pulldown try to activate a task from the "Run Executable" 
   item.
4. View the following backtrace:

(No exception message provided)

java.lang.NullPointerException
   at frysk.rt.SteppingEngine.addProc(SteppingEngine.java:189)
   at
frysk.gui.srcwin.SourceWindowFactory$AttachedObserver.updateAttached(SourceWindowFactory.java:280)
   at frysk.proc.Task.notifyAttached(Task.java:568)
   at
frysk.proc.LinuxPtraceTaskState$Attached.transitionToRunningState(LinuxPtraceTaskState.java:285)
   at
frysk.proc.LinuxPtraceTaskState$StartMainTask$6.blockOrAttachContinue(LinuxPtraceTaskState.java:523)
   at
frysk.proc.LinuxPtraceTaskState$StartMainTask$6.handleTrappedEvent(LinuxPtraceTaskState.java:528)
   at frysk.proc.Task.processTrappedEvent(Task.java:369)
   at frysk.proc.LinuxPtraceWaitBuilder.stopped(LinuxPtraceWaitBuilder.java:202)
   at frysk.sys.Wait.wait(Wait.cxx:568)
   at frysk.sys.Wait.waitAll(Wait.java:106)
   at frysk.event.WaitEventLoop.block(WaitEventLoop.java:83)
   at frysk.event.EventLoop.runEventLoop(EventLoop.java:380)
   at frysk.event.EventLoop.run(EventLoop.java:485)
   at frysk.gui.Gui$4.run(Gui.java:367)
   at java.lang.Thread.run(libgcj.so.7)
Comment 1 Rick Moseley 2007-04-21 05:08:55 UTC
The above comes out in a Frysk Core warning window, the following comes out in
the terminal window when the bash task is terminated and before attempting to
activate a new task:

threadlife: Terminating:
{frysk.proc.LinuxPtraceTask@9b78c0,pid=23855,tid=23855,state=running} 1
Processes exited 0
java.lang.NullPointerException
   at frysk.rt.SteppingEngine.isTaskRunning(SteppingEngine.java:842)
   at frysk.gui.srcwin.SourceWindow.isRunning(SourceWindow.java:783)
   at
frysk.gui.srcwin.SourceView$SourceViewListener.mouseMotionEvent(SourceView.java:1024)
   at org.gnu.gtk.Widget.fireMouseMotionEvent(libgtkjava-2.8.so)
   at org.gnu.gtk.Widget.handleMouseMotion(libgtkjava-2.8.so)
   at org.gnu.gtk.Gtk.gtk_main(libgtkjava-2.8.so)
   at org.gnu.gtk.Gtk.main(libgtkjava-2.8.so)
   at frysk.gui.Gui.gui(Gui.java:244)
   at frysk.gui.FryskGui.main(FryskGui.java:59)
Comment 2 Mike Cvet 2007-04-23 17:01:44 UTC
2007-04-23  Mike Cvet  <mcvet@redhat.com>

	* SteppingEngine.java (contextMap): Changed to synchronized HashMap.
	(tasks, stateProc, taskStepCount, current): Removed.
	(threadsList): Added. List of Tasks to be blocked.
	(setProc): Heavily cleaned up, fixed to use threadsList.
	(setProcs): Ditto.
	(addProc): Dito.
	(stepInstruction): Ditto. Uses contextMap to keep track of number of
	stepping threads.
	(setUpLineStep): Removed reference to taskStepCount.
	(setUpStepNextInstruction): Ditto.
	(setUpStepOver): Ditto.
	(setUpStepOut): Ditto.
	(continueExecution): Removed reference to old Tasks array.
	(stop): Ditto. Ensure that Tasks don't get added to threadsList
	more than once. Synchronized on threadsList.
	(blockTask): Removed.
	(executeTasks): Made use of threadsList.
	(isProcRunning): Assume if Task no longer exists in SteppingEngine
	data structures, it has exited and thus not running. Fixes #4401.
	(isTaskRunning): Ditto.
	(updateExecuted): Check number of remaining Tasks to be blocked before
	notifying any Observers. Update the number of remaining Tasks in the
	contextMap. If there are Tasks to be blocked, block them and return.
	Fixes #4399.
	(requestAdd): Rewritten. Faster, empties Tasks out of threadsList and
	blocks each as individual Tasks rather than threads of a process.
	(ThreadLifeObservable): Initialize threadsList.
	(ThreadLifeObservable.updateClonedOffspring): Don't explicitly block
	new Tasks with the steppingObserver. Update contextMap with new Task
	and put new Task in threadsList. Fixes #4399.
Comment 3 Rick Moseley 2007-04-23 18:40:24 UTC
Hmmmm, on my FC5/i386 machine when I now exit the bash shell, it does not leave
the Source Window stack frame window plus, it appears to hang up and if I try to
click on the "stop" icon I get the following:

java.lang.NullPointerException
   at frysk.rt.SteppingEngine.stop(SteppingEngine.java:647)
   at frysk.gui.srcwin.SourceWindow.doStop(SourceWindow.java:2150)
   at frysk.gui.srcwin.SourceWindow$13.actionEvent(SourceWindow.java:1049)
   at org.gnu.gtk.Action.fireActionEvent(libgtkjava-2.8.so)
   at org.gnu.gtk.Action.handleActivate(libgtkjava-2.8.so)
   at org.gnu.gtk.Gtk.gtk_main(libgtkjava-2.8.so)
   at org.gnu.gtk.Gtk.main(libgtkjava-2.8.so)
   at frysk.gui.Gui.gui(Gui.java:244)
   at frysk.gui.FryskGui.main(FryskGui.java:59)
Comment 4 Rick Moseley 2007-04-24 19:15:18 UTC
Appears to be fixed with latest checkins for the SourceWindow and RTEngine.