Skip to content

Commit

Permalink
if debugger is closed, make sure to terminate the forked loopWhile:
Browse files Browse the repository at this point in the history
#927

Added simple test based on Lisa's reproduction case. test_debuggerDoesNotFreeze2
  • Loading branch information
Eric Winger authored and Eric Winger committed Oct 11, 2022
1 parent eafda47 commit 141ee90
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
13 changes: 10 additions & 3 deletions sources/JadePresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,22 @@ waitForAnswer: thingThatCanAnswer
loopWhile: [deferredValue hasValue not and: [thingThatCanAnswer isDeafObject not]]]
fork.
(Delay forMilliseconds: 1) wait.
[loop isAlive] whileTrue: [(Delay forMilliseconds: 1) wait]].
[loop isAlive] whileTrue:
[thingThatCanAnswer isDeafObject
ifTrue:
[loop terminate.
^nil].
(Delay forMilliseconds: 1) wait]].
theAnswer := [deferredValue value] on: Error
do:
[:ex |
ex messageText = 'DeferredValue terminated prematurely'
ifTrue: [nil]
ifFalse:
[thingThatCanAnswer getProcessList; update. "should be a debugger so update"
self waitForAnswer: thingThatCanAnswer ]].
[thingThatCanAnswer
getProcessList;
update. "should be a debugger so update"
self waitForAnswer: thingThatCanAnswer]].
^theAnswer! !
!JadePresenter class categoriesForMethods!
areAbortCommitEnabled!public! !
Expand Down
42 changes: 40 additions & 2 deletions sources/JadeiteDebuggerTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ test_debugFromWithinInspector
self assert: debugger model value equals: 'nil halt. self size']
ensure: [inspector view close]!

test_debuggerDoesNotFreeze
test_debuggerDoesNotFreeze1
"tests one of the many ways the debugger would freeze the gui. If test completes
we didn't freeze."

Expand Down Expand Up @@ -884,6 +884,43 @@ test_debuggerDoesNotFreeze
[workspace isModified: false.
workspace view close]!

test_debuggerDoesNotFreeze2
"tests one of the many ways the debugger would freeze the gui. If test completes
we didn't freeze."

| workspace debuggersDestroyed |
self testsIssue: #issue927 withTitle: '[3.2.9] Concurrent debuggers can hang Jadeite'.
workspace := JadeWorkspace showOnSession: session.

[self assert: (workspace isKindOf: JadeWorkspace).
workspace setDocumentData: 'Array new: 1'.
self debuggerDo:
[process :=
[workspace codePane documentPresenter setFocus.
workspace codePane documentPresenter view selectAll.
workspace codePane jadeDebug]
forkAt: Processor activePriority + 1].
self getDebugger.
debugger variableDataPresenter value: 'String new halt'.
debugger variableDataPresenter view selectAll.
[debugger jadeExecute] fork.
self getSecondDebugger.
self assert: (secondDebugger isKindOf: JadeiteDebugger).
debuggersDestroyed := false.

[self destroy: debugger.
self destroy: secondDebugger.
debuggersDestroyed := true] fork.
[debuggersDestroyed] whileFalse: [(Delay forMilliseconds: 50) wait].
workspace setDocumentData: '#foo'.
workspace codePane documentPresenter setFocus.
workspace codePane documentPresenter view selectAll.
workspace codePane jadeDisplay.
self assert: workspace codePane documentPresenter value = '#foo #''foo''']
ensure:
[workspace isModified: false.
workspace view close]!

test_debuggerModifiedSourcePaneChangeFrame
self testsIssue: #issue120 withTitle: 'Debugger, edits in text, copy to clipboard, get error'.
TestMessageBox enableJadeiteTestMessageBox.
Expand Down Expand Up @@ -2500,7 +2537,8 @@ test_debugCodeWithLeadingLineReturns!public! !
test_debugCodeWithLeadingLineReturnsLF!public! !
test_debugCodeWithLeadingTab!public! !
test_debugFromWithinInspector!public!tests! !
test_debuggerDoesNotFreeze!public!test ad hoc execution! !
test_debuggerDoesNotFreeze1!public!test ad hoc execution! !
test_debuggerDoesNotFreeze2!public!test ad hoc execution! !
test_debuggerModifiedSourcePaneChangeFrame!public!tests! !
test_debuggerModifiedSourcePaneStayOnFrame!public!tests! !
test_disablebreakpointHighlighting!public!tests! !
Expand Down
2 changes: 1 addition & 1 deletion sources/Rowan UI Base.pax
Original file line number Diff line number Diff line change
Expand Up @@ -5043,7 +5043,7 @@ jadeExecuteAndDisplay: showResult
newProcess
name: 'GciSession';
resume.
[result isNil] whileTrue: [(Delay forMilliseconds: 10) wait].
(Delay forMilliseconds: 10) wait.
^result!

jadeExecuteAndDisplay: showResult view: focusViewOrNil
Expand Down

0 comments on commit 141ee90

Please sign in to comment.