Bug 4431 - AckDaemonProcess doesn't appear to fully wait
Summary: AckDaemonProcess doesn't appear to fully wait
Status: RESOLVED FIXED
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Mike Cvet
URL:
Keywords:
Depends on:
Blocks: 2935 3346 4289 4394
  Show dependency treegraph
 
Reported: 2007-04-26 16:28 UTC by Mike Cvet
Modified: 2007-04-30 22:25 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Cvet 2007-04-26 16:28:48 UTC
In most of the RT testcases, AckDaemonProcesses are used to start up a test 
process. However, often, (usually second iteration of the test), the test will 
fail becase the grabbed stack trace is not a proper stack trace of the process, 
and as noticed in #4394:

"I grabbed some stack traces of the traced process, and ended up with varying 
results, including the following:

#0 0x00002aaaaaab1a2b in _dl_map_object_from_fd ()
#1 0x00002aaaaaab2d9c in _dl_map_object ()
#2 0x00002aaaaaab610d in openaux ()
#3 0x00002aaaaaab7d26 in _dl_catch_error ()
#4 0x00002aaaaaab67d6 in _dl_map_object_deps ()
#5 0x00002aaaaaaae306 in dl_main ()
#6 0x00002aaaaaabde0b in _dl_sysdep_start ()
#7 0x00002aaaaaaac468 in _dl_start ()
#8 0x00002aaaaaaabb58 in [unknown]

or

#0 0x00002aaaaaabeff6 in strcmp ()
#1 0x00002aaaaaab3c87 in check_match.8134 ()
#2 0x00002aaaaaab4084 in do_lookup_x ()
#3 0x00002aaaaaab4282 in _dl_lookup_symbol_x ()
#4 0x00002aaaaaab57a5 in _dl_relocate_object ()
#5 0x00002aaaaaaae77a in dl_main ()
#6 0x00002aaaaaabde0b in _dl_sysdep_start ()
#7 0x00002aaaaaaac468 in _dl_start ()
#8 0x00002aaaaaaabb58 in [unknown]

or 

#0 0x00002aaaaaab7bc3 in _dl_fixup ()
#1 0x00002aaaaaabd3a2 in _dl_runtime_resolve ()
#2 0x00002aaaaaccb628 in __pthread_initialize_minimal ()
#3 0x00002aaaaaccaf29 in _init ()

or just plain:

#0 0x00002aaaaaabeff4 in [unknown]"

The relevant code is usually something like:

    AckDaemonProcess process = new AckDaemonProcess
	(Sig.POLL, new String[] {
	    getExecPath ("funit-rt-threader"),
	    "" + Pid.get (),
	    "" + Sig.POLL_
	});
        
    myTask = process.findTaskUsingRefresh(true);
    SteppingEngine.setProc(myTask.getProc());

However, the problem is mitigated by placing 

    try { Thread.sleep(500); } catch (Exception e) {}

between the initialization of the AckDaemonProcess, and the call to 
SteppingEngine. It appears as though the process needs time to fully load and 
start running before the test begins.
Comment 1 Mike Cvet 2007-04-26 18:53:19 UTC
Without the sleep call, may give errors such as the following:

1) testBacktrace(frysk.rt.TestStackBacktrace)java.lang.RuntimeException: Failed 
to attach to created proc
   at frysk.rt.SteppingEngine$ThreadLifeObservable.addFailed(TestRunner)
   at frysk.proc.LinuxPtraceTaskState$16.handleAddObservation(TestRunner)
   at frysk.proc.Task.handleAddObservation(TestRunner)
   at frysk.proc.TaskObservation.handleAdd(TestRunner)
   at frysk.proc.LinuxPtraceProcState$Attaching.allAttached(TestRunner)
   at 
frysk.proc.LinuxPtraceProcState$Attaching$ToMainTask.handleTaskAttachCompleted(TestRunner)
   at frysk.proc.Proc$4.execute(TestRunner)
   at frysk.event.EventLoop.runEventLoop(TestRunner)
   at frysk.event.EventLoop.runPolling(TestRunner)
   at frysk.proc.TestLib.assertRunUntilStop(TestRunner)
   at frysk.proc.TestLib.assertRunUntilStop(TestRunner)
   at frysk.rt.TestStackBacktrace.testBacktrace(TestRunner)
   at frysk.junit.Runner.runCases(TestRunner)
   at frysk.junit.Runner.runArchCases(TestRunner)
   at frysk.junit.Runner.runTestCases(TestRunner)
   at TestRunner.main(TestRunner)
Caused by: java.lang.RuntimeException: destroyed
   at frysk.proc.LinuxPtraceTaskState$16.handleAddObservation(TestRunner)
   ...27 more
2) 
testThreadedBacktrace(frysk.rt.TestStackBacktrace)java.lang.RuntimeException: 
getting task's executable
   at frysk.proc.IsaFactory.getIsa(TestRunner)
   at frysk.proc.IsaFactory.getIsa(TestRunner)
   at frysk.proc.LinuxPtraceTask.sendrecIsa(TestRunner)
   at frysk.proc.Task.getIsa(TestRunner)
   at frysk.rt.StackCallbacks.<init>(TestRunner)
   at frysk.rt.StackFactory.createStackFrame(TestRunner)
   at frysk.rt.StackFactory.createStackFrame(TestRunner)
   at frysk.rt.TestStackBacktrace.firstTestBacktraceAssertions(TestRunner)
   at frysk.rt.TestStackBacktrace$LockObserver.update(TestRunner)
   at java.util.Observable.notifyObservers(libgcj.so.7rh)
   at frysk.rt.SteppingEngine$SteppingObserver.updateExecuted(TestRunner)
   at frysk.proc.Proc$14.add(TestRunner)
   at frysk.proc.LinuxPtraceTaskState$Attached.handleAddObservation(TestRunner)
   at frysk.proc.Task.handleAddObservation(TestRunner)
   at frysk.proc.TaskObservation.handleAdd(TestRunner)
   at frysk.proc.LinuxPtraceProcState$Attaching.allAttached(TestRunner)
   at 
frysk.proc.LinuxPtraceProcState$Attaching$ToOtherTasks.handleTaskAttachCompleted(TestRunner)
   at frysk.proc.Proc$4.execute(TestRunner)
   at frysk.event.EventLoop.runEventLoop(TestRunner)
   at frysk.event.EventLoop.runPolling(TestRunner)
   at frysk.proc.TestLib.assertRunUntilStop(TestRunner)
   at frysk.proc.TestLib.assertRunUntilStop(TestRunner)
   at frysk.rt.TestStackBacktrace.testThreadedBacktrace(TestRunner)
   at frysk.junit.Runner.runCases(TestRunner)
   at frysk.junit.Runner.runArchCases(TestRunner)
   at frysk.junit.Runner.runTestCases(TestRunner)
   at TestRunner.main(TestRunner)
Caused by: lib.elf.ElfFileException: Could not open /proc/12927/exe
   at lib.elf.Elf.<init>(TestRunner)
   at frysk.proc.IsaFactory.getIsa(TestRunner)
   ...39 more
Comment 2 Andrew Cagney 2007-04-30 20:28:21 UTC
Frysk uses SIGIO (SIGPOLL is an alias) internally.  Try a signal like SIGUSR1.
Comment 3 Mike Cvet 2007-04-30 23:25:13 UTC
Sig.USR1 fixes the problem
Comment 4 Mike Cvet 2007-04-30 23:25:23 UTC
	* TestStepping.java (testLineStepFunctionCall): Use Sig.USR1
	instead of Sig.POLL. Fixes #4431.
	(testLineStepIfStatementPass): Ditto.
	(testLineStepIfStatementFail): Ditto.
	(testLineStepFunctionReturn): Ditto.
	(testStepSigLongJmp): Ditto.
	(testStepGoto): Ditto.
	(testStepSigRaise): Ditto.
	* TestSteppingEngine.java (testInstructionStepping): Ditto.
	(testLineStepping): Ditto.
	(testStepOver): Ditto.
	(testInstructionNext): Ditto.
	(testStepOut): Ditto.