Random exceptions terminating root process

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

Random exceptions terminating root process

Tony Garnock-Jones-2
Hi,

Here's the test case code I mentioned earlier. It's probably my code
that's at fault, rather than the VM, but it's still very strange behaviour.

When you run TerminationExperiment's #run, it can sometimes reach
several tens of thousands of iterations of busyLoop before faulting, but
will often fault before 20,000 iterations have completed on my machine.

When you run #run2, things behave as I would have expected them to
behave. No faulting occurs, and the process is sensibly terminated.

Here's a selection of some of the faults I see from #run after several
seconds. Each comes at the end of a single run of the script, as attached.

Object: '' error: Invalid argument : must be a SmallInteger
SystemExceptions.WrongClass(Exception)>>signal
SystemExceptions.WrongClass class>>signalOn:mustBe:
SystemExceptions.WrongClass class>>signalOn:mustBe:
String(Object)>>checkIndexableBounds:put:
String>>at:put:
String class(ArrayedCollection class)>>with:
Character>>asString
[] in TextCollector>>showCr:
[] in Semaphore>>critical:
BlockClosure>>ensure:
Semaphore>>critical:
TextCollector>>showCr:
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements

Object: nil error: did not understand #generality
MessageNotUnderstood(Exception)>>signal
UndefinedObject(Object)>>doesNotUnderstand: #generality
SmallInteger>>+
FileStream(FileDescriptor)>>write:from:to:
FileStream>>flush
FileStream(Stream)>>nextPutAllFlush:
TextCollector>>primNextPutAll:
[] in TextCollector>>showCr:
[] in Semaphore>>critical:
BlockClosure>>ensure:
Semaphore>>critical:
TextCollector>>showCr:
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements

Object: String error: Invalid argument 'b': must be a SmallInteger
SystemExceptions.WrongClass(Exception)>>signal
SystemExceptions.WrongClass class>>signalOn:mustBe:
SystemExceptions.WrongClass class>>signalOn:mustBe:
String class(Behavior)>>new:
String(Collection)>>copyEmpty:
String(ArrayedCollection)>>copyFrom:to:
WriteStream>>contents
String(Object)>>printString
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements

Object: 3 error: did not understand #replaceFrom:to:with:startingAt:
MessageNotUnderstood(Exception)>>signal
SmallInteger(Object)>>doesNotUnderstand: #replaceFrom:to:with:startingAt:
String(ArrayedCollection)>>copyFrom:to:
WriteStream>>contents
String(Object)>>printString
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements


This one includes the end of the stdout, to illustrate an odd doubling
of 'c':

'a'
'b'
'c''c'Object: nil error: did not understand #generality
MessageNotUnderstood(Exception)>>signal
UndefinedObject(Object)>>doesNotUnderstand: #generality
SmallInteger>>+
FileStream(FileDescriptor)>>write:from:to:
FileStream>>flush
FileStream(Stream)>>nextPutAllFlush:
TextCollector>>primNextPutAll:
[] in TextCollector>>showCr:
[] in Semaphore>>critical:
BlockClosure>>ensure:
Semaphore>>critical:
TextCollector>>showCr:
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements

Object: String error: did not understand #copyEmpty:
MessageNotUnderstood(Exception)>>signal
String class(Object)>>doesNotUnderstand: #copyEmpty:
WriteStream>>growCollection
WriteStream>>nextPut:
String>>printOn:
String(Object)>>printString
String(Object)>>printNl
TerminationExperiment>>busyLoop
TerminationExperiment>>run
UndefinedObject>>executeStatements

etc. etc.

Tony
--
 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: [hidden email]

Object subclass: TerminationExperiment [
    busyLoop [
        | ptr count |
        count := 0.
        [
            'a' printNl.
            'b' printNl.
            'c' printNl.
            count := count + 1.
            (count \\ 100) = 0 ifTrue: [
                Transcript << 'count: ' << count; nl.
                Processor yield].
        ] repeat.
    ]

    run [
        | p |
        p := Processor activeProcess.
        p printNl.
        [
            Processor activeProcess printNl.
            [
                (Delay forMilliseconds: 1000) wait.
                p terminate.
            ] repeat.
        ] fork.
        self busyLoop.
    ]

    run2 [
        | p s |
        s := Semaphore new.
        p := [ [self busyLoop] ensure: [s signal] ] fork.
        p printNl.
        [
            Processor activeProcess printNl.
            [
                (Delay forMilliseconds: 1000) wait.
                p terminate.
            ] repeat.
        ] fork.
        s wait.
    ]
].

TerminationExperiment new run.
"TerminationExperiment new run2."

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Random exceptions terminating root process

Paolo Bonzini
Tony Garnock-Jones wrote:
> Hi,
>
> Here's the test case code I mentioned earlier. It's probably my code
> that's at fault, rather than the VM, but it's still very strange behaviour.

No, it's the VM.  You're right -- it's a bad idea to terminate a
CallinProcess and I knew that but forgot today; it wouldn't terminate at
all if it was not for those random exceptions (which are a different
bug).  Please file the bug report and attach the code there too.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk