pharo-contributions / taskit

TaskIt is a library that ease Process usage in Pharo. It provides abstractions to execute and synchronize concurrent tasks, and several pre-built mechanisms that are useful for many application developers.
MIT License
43 stars 24 forks source link

Pharo 10 signals error on TKTRawProcess>>isTerminated #114

Closed tinchodias closed 2 years ago

tinchodias commented 2 years ago

Strangely, not in Pharo 9.

The top of stack is:

KeyNotFound: key #endProcess not found in MethodDictionary
MethodDictionary(Dictionary)>>errorKeyNotFound:
[self errorKeyNotFound: key] in MethodDictionary(Dictionary)>>at:
MethodDictionary>>at:ifAbsent:
MethodDictionary(Dictionary)>>at:
TKTRawProcess class(Behavior)>>compiledMethodAt:
TKTRawProcess class(Behavior)>>>>
TKTRawProcess(Process)>>isTerminated

It comes from:

Process >>
isTerminated

    "Answer if the receiver is terminated, i.e. if the receiver is not active and 
    one of the following conditions is met:
    (1) the receiver is a defunct process (suspendedContext = nil or pc = nil)
    (2) the receiver is suspended in the endProcess method (We cannot use pragmas... pragmas require the compiler, it generates an evil dependency.
    It also is not available in minimal images)"

    self isActiveProcess ifTrue: [ ^ false ].

    ^suspendedContext isNil or: [
        suspendedContext isDead or: [
            (suspendedContext method == (self class >> #endProcess))]]
tinchodias commented 2 years ago

Aha! in Pharo 9, this method was different. I will report it on Pharo 10:

Process >>
isTerminated
    self isActiveProcess ifTrue: [ ^ false ].

    ^ suspendedContext isNil or: [
        "If the suspendedContext is the bottomContext it is the block in Process>>newProcess.
        If so, and the pc is greater than the startpc, the block has already sent and returned
        from value and there is nothing more to do."
        suspendedContext isBottomContext and: [
            suspendedContext isDead or: [
                "The pc of the suspendedContext is set to nil in #terminate explicitly.
                Leaving this line in for safety."
                suspendedContext pc > suspendedContext startpc ] ] ]
tinchodias commented 2 years ago

Reported as https://github.com/pharo-project/pharo/issues/11121