Bug in Process>>suspendUnconditionally

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in Process>>suspendUnconditionally

Udo Schneider
Andy, Blair,

It seems that there is a bug in Process>>suspendUnconditionally. The
following code raises an error:
process := [Transcript
        show: 'Hello world';
        cr] newProcess.
process suspendUnconditionally.


As far as I can see the failed Primitive handling code expects
primitiveFailureCode to be a value between 0-2 whereas the actual code
returned is nil (which is at least somehow correct as 0 would be the
"expected" error code in this case).

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Bug in Process>>suspendUnconditionally

Blair McGlashan-4
"Udo Schneider" <[hidden email]> wrote in message
news:[hidden email]...

> Andy, Blair,
>
> It seems that there is a bug in Process>>suspendUnconditionally. The
> following code raises an error:
> process := [Transcript
> show: 'Hello world';
> cr] newProcess.
> process suspendUnconditionally.
>
>
> As far as I can see the failed Primitive handling code expects
> primitiveFailureCode to be a value between 0-2 whereas the actual code
> returned is nil (which is at least somehow correct as 0 would be the
> "expected" error code in this case).
>

Actually the problem here is that the primitive is accessing the failure
code directly from the instance variable in the process. The primitives
store the failure code into the active process (which makes sense in a
multi-threaded system), but of course the process you are attempting to
suspend is not the active one in this case. The code should look like that
below.

Thanks for the report

Blair
------------------
!Process methodsFor!

suspendUnconditionally
 "As #suspend, but fails silently attempts at suspending processes which are
already Suspended.
 Answers the receiver.

 Primitive failure results:
  0 - the process is already suspended.
  1 - the process is the active process and could not be suspended because
   it is the only runnable process remaining.
  2- the process is pending termination

 The first two failure codes are ignored. Any other failure code is
unexpected, and will result in
 normal failure handling."

 | failureCode |
 <primitive: 88>
 failureCode := Processor activeProcess primitiveFailureCode.
 ^failureCode == 1
  ifTrue: [false]
  ifFalse: [failureCode == 0 ifTrue: [self] ifFalse: [self
primitiveFailed]]! !
!Process categoriesFor: #suspendUnconditionally!public!states-changing! !