Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2574.mcz==================== Summary ====================
Name: VMMaker.oscog-nice.2574
Author: nice
Time: 28 October 2019, 7:13:28.153845 pm
UUID: 97ff56d4-01fb-422a-8b6c-edaa2d57bbde
Ancestors: VMMaker.oscog-nice.2573
Fix issue 436 again
if msecs is usqInt, then the subtraction msecs - ioMsecs() is performed as unsigned 32bits, and can lead to high value instead of slightly negative value, which remain positive when converted to 64 bit signed long deltaMsecs...
That makes a near 48 days delay before waking up!
The expression must be evaluated with 64bits signed long arithmetic, what we obtain by declaring msecs as sqLong...
When we write C code, we must think in C language, not upper level language with exact integer arithmetic (no wrap, no overflow), that's a potential danger of Slang...
=============== Diff against VMMaker.oscog-nice.2573 ===============
Item was changed:
----- Method: StackInterpreterPrimitives>>primitiveSignalAtMilliseconds (in category 'system control primitives') -----
primitiveSignalAtMilliseconds
"Cause the time semaphore, if one has been registered, to be
signalled when the microsecond clock is greater than or equal to
the given tick value. A tick value of zero turns off timer interrupts."
| msecsObj msecs deltaMsecs sema limit |
+ <var: #msecs type: #sqLong>
- <var: #msecs type: #usqInt>
<var: #deltaMsecs type: #sqLong>
<var: #limit type: #sqLong>
msecsObj := self stackTop.
sema := self stackValue: 1.
msecs := self positive32BitValueOf: msecsObj.
self successful ifTrue:
[(objectMemory isSemaphoreOop: sema) ifTrue:
[objectMemory splObj: TheTimerSemaphore put: sema.
deltaMsecs := msecs - (self ioMSecs bitAnd: MillisecondClockMask).
limit := MillisecondClockMask >> 1.
"Handle a roll-over that could happen in between image invocation of ioMSecs and this invocation.
This will limit the maximum relative duration to MillisecondClockMask/2, about 3 days currently.
Every delay longer than that limit may lead to undefined behavior (shorten delay, or no delay at all)"
deltaMsecs > limit ifTrue: [deltaMsecs := deltaMsecs - MillisecondClockMask].
nextWakeupUsecs := deltaMsecs > 0
ifTrue: [self ioUTCMicroseconds + (deltaMsecs * 1000)]
ifFalse: [self ioUTCMicroseconds].
^self pop: 2].
sema = objectMemory nilObject ifTrue:
[objectMemory
storePointer: TheTimerSemaphore
ofObject: objectMemory specialObjectsOop
withValue: objectMemory nilObject.
nextWakeupUsecs := 0.
^self pop: 2]].
self primitiveFailFor: PrimErrBadArgument!