SoarGroup / Soar

Soar, a general cognitive architecture for systems that exhibit intelligent behavior.
http://soar.eecs.umich.edu
Other
322 stars 70 forks source link

debugger errors after deleting agent #435

Open garfieldnate opened 3 months ago

garfieldnate commented 3 months ago

1) open debugger 2) Agents->Create Agent - New Window 3) In new agent window, Agents -> Destroy Agent 4) On remaining agent window, "step"

Prints these errors:

~ Error: Error binding the listener socket to its port number
Failed to create the internet listener socket.  Shutting down listener thread.
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed))))))))))
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed))))))))))
    at org.eclipse.swt.SWT.error(SWT.java:4918)
    at org.eclipse.swt.SWT.error(SWT.java:4833)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4368)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3991)
    at edu.umich.soar.debugger.doc.Document.pumpMessagesOneStep(Document.java:1100)
    at edu.umich.soar.debugger.doc.Document.sendAgentCommandGeneral(Document.java:1207)
    at edu.umich.soar.debugger.doc.Document.sendAgentCommand(Document.java:1147)
    at edu.umich.soar.debugger.modules.AbstractComboView.executeAgentCommand(AbstractComboView.java:634)
    at edu.umich.soar.debugger.modules.AbstractComboView.commandEntered(AbstractComboView.java:455)
    at edu.umich.soar.debugger.modules.AbstractComboView.comboKeyPressed(AbstractComboView.java:315)
    at edu.umich.soar.debugger.modules.AbstractComboView$1.keyPressed(AbstractComboView.java:217)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:171)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4646)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1547)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1532)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1561)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1557)
    at org.eclipse.swt.widgets.Combo.sendKeyEvent(Combo.java:1458)
    at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1085)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:6492)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:236)
    at org.eclipse.swt.widgets.Widget.superKeyDown(Widget.java:2074)
    at org.eclipse.swt.widgets.Widget.keyDown(Widget.java:1131)
    at org.eclipse.swt.widgets.Control.keyDown(Control.java:2457)
    at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:620)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:6324)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:236)
    at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2264)
    at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2511)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:6444)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5692)
    at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5831)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:117)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3986)
    at edu.umich.soar.debugger.doc.Document.pumpMessagesTillClosed(Document.java:1080)
    at edu.umich.soar.debugger.SWTApplication.startApp(SWTApplication.java:295)
    at edu.umich.soar.debugger.Application.<init>(Application.java:31)
    at edu.umich.soar.debugger.Application.main(Application.java:54)
Caused by: org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)))))))))
    at org.eclipse.swt.SWT.error(SWT.java:4918)
    at org.eclipse.swt.SWT.error(SWT.java:4833)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4368)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3991)
    at edu.umich.soar.debugger.doc.Document.pumpMessagesOneStep(Document.java:1100)
    at edu.umich.soar.debugger.doc.Document.sendAgentCommandGeneral(Document.java:1207)
    at edu.umich.soar.debugger.doc.Document.sendAgentCommand(Document.java:1147)
    at edu.umich.soar.debugger.modules.AbstractComboView.executeAgentCommand(AbstractComboView.java:634)
    at edu.umich.soar.debugger.modules.AbstractComboView.commandEntered(AbstractComboView.java:455)
    at edu.umich.soar.debugger.modules.AbstractComboView.lambda$updateNow$1(AbstractComboView.java:590)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
    ... 42 more

Note that this issue does not occur if you close the window without destroying the agent.

I suppose that the print listener for the window is not being deregistered, and thus it fires and tries to print in a non-existent window.

garfieldnate commented 3 months ago

This is caused by our firing some agent logic on separate threads while in the actual SML before-agent-destroyed handler. Once the logic runs, the agent is already gone, and this line takes note of that and calls fireAgentGone instead of fireAgentLosingFocus. All of the event deregistration happens in fireAgentLosingFocus, including system events, which are not dependent on the agent and will continue to be fired after the agent is destroyed.

There are some obvious looking fixes (run the logic in the current thread instead of separate threads), but there are some very threatening-looking comments about potential deadlocks and such, so I'd rather avoid that. I think the proper fix is to separate the kernel-dependent and the agent-dependent event registration/de-registration.