Mantis - Squeak
Viewing Issue Advanced Details
7320 VM minor always 03-22-09 03:59 03-30-09 09:55
mikevdg  
mikevdg  
normal  
assigned 3.9  
open  
none    
none  
0007320: Seg fault on image start-up; EventSensor suspected.
Hi VM guys.

Does anybody have any insights into the following?:

I get the following crash. I've tried this on a Windows VM of unknown version and a 3.9-alpha Linux VM with the same result:

Segmentation fault

-1528952856 [] in Semaphore>critical:
-1528953680 BlockContext>ensure:
-1528953772 Semaphore>critical:
-1528953864 >clearExternalObjects
-1528953956 SystemDictionary>clearExternalObjects
-1529116848 SmalltalkImage>snapshot:andQuit:embedded:
-1529116940 SmalltalkImage>snapshot:andQuit:
-1529117032 TheWorldMenu>saveAndQuit
-1529117216 TheWorldMenu>doMenuItem:with:
-1529117308 [] in MenuItemMorph>invokeWithEvent:
-1529117400 BlockContext>ensure:
-1529117492 Cursor>showWhile:
-1529117712 MenuItemMorph>invokeWithEvent:
-1529117804 MenuItemMorph>mouseUp:
-1529117896 MenuItemMorph>handleMouseUp:
-1529118028 MouseButtonEvent>sentTo:
-1529118120 Morph>handleEvent:
-1529118212 MorphicEventDispatcher>dispatchDefault:with:
-1529118304 MorphicEventDispatcher>dispatchEvent:with:
-1529118396 Morph>processEvent:using:
-1529118488 MorphicEventDispatcher>dispatchDefault:with:
-1529118596 MorphicEventDispatcher>dispatchEvent:with:
-1529118728 Morph>processEvent:using:
-1529118820 Morph>processEvent:
-1529118912 MenuMorph>handleFocusEvent:
-1529119188 [] in HandMorph>sendFocusEvent:to:clear:
-1529119096 [] in PasteUpMorph>becomeActiveDuring:
-1529119280 BlockContext>on:do:
-1529119372 PasteUpMorph>becomeActiveDuring:
-1529119556 HandMorph>sendFocusEvent:to:clear:
-1529119648 HandMorph>sendEvent:focus:clear:
-1529119740 HandMorph>sendMouseEvent:
-1529119884 HandMorph>handleEvent:
-1529120168 HandMorph>processEvents
-1529120076 [] in WorldState>doOneCycleNowFor:
-1529120260 SequenceableCollection>do:
-1529120352 WorldState>handsDo:
-1529120444 WorldState>doOneCycleNowFor:
-1529120536 WorldState>doOneCycleFor:
-1529120628 PasteUpMorph>doOneCycle
-1529214452 [] in >spawnNewProcess
-1529214268 [] in BlockContext>newProcess
Segmentation fault (core dumped)

This happens on start-up. None of the VM flags I tried make a difference.

I suspect this may have caused it:

!EventSensor methodsFor: 'as yet unclassified' stamp: 'mvdg 3/17/2009 21:54' prior: 36505616!
startUp
 [
  panicButtonPressed := false.

  Smalltalk.Sensor shutDown.
  inputSemaphore := Semaphore new.
  Smalltalk.ExternalSemaphoreTable registerExternalObject: inputSemaphore.
  self primSetInputSemaphore: inputSemaphore.

  self enterEventLoop.
 ] ensure: [
  Smalltalk.Sensor startUp.
  Smalltalk.Display restore.
 ].! !


This code worked fine until I saved, quit and tried to reopen the image.

Note that this class is actually defined in my namespaces implementation - it does not exist in the SystemDictionary and has it's environment set to an instance of Namespace. It is my own implementation of EventSensor and I've added the primitive methods to it. I'm not sure if any of this matters.

(mikevdg/gulik note to self: image in ~/dpon/subcanvas-crashes/. Email Gulik for this image.)
 07320-inputSemaphore-fix.2.cs [^] (1,196 bytes) 03-30-09 09:52

Notes
(0013057)
mikevdg   
03-22-09 07:58   
To recreate:

Sensor primSetInputSemaphore: (Semaphore new).
Save the image.
The image will then crash on loading.
(0013058)
mikevdg   
03-22-09 20:36   
primSetInputSemaphore: takes an index into the external objects table rather than a Semaphore. To quote a great contributer to modern culture: "Doh!".

Need to:

- rename primSetInputSemaphore: to primSetInputSemaphoreIndex:.
- Add checks in the VM: must be a SmallInteger, must be a valid index in the external objects table, must point to a Semaphore.
- Add error handling code in the method itself.
(0013059)
mikevdg   
03-23-09 09:01   
Looking at VM source, primSetInputSemaphore: takes either an integer, Semaphore or any other object as arg. If any other object, the current value gets nilled.

Code in Interpreter>>primitiveInputSemaphore is broken; TheInputSemaphore is undefined. It was defined in Object>>initializeSpecialObjectIndices, but somebody has clobberred and re-used special object 22 for ProcessSignallingLowSpace.

C code also gives a jolly good hint in interp.c:
#define TheInputSemaphore null
(that can't be healthy).

ioSetInputSemaphore for Unix (sqUnixMain.c) fails if events disabled.
(0013060)
mikevdg   
03-23-09 10:17   
The attached changeset ( 07320-inputSemaphore-fix.2.cs) is my first attempt at fixing this, but my VM just stopped working. Somebody else will need to pick it up and see if it works.
(0013069)
mikevdg   
03-30-09 09:55   
This latest attachment has been tested by me.

Tests run (manually):
- Invoking with a newly registered Semaphore object in the external object array (works as expected).
- Invoking with a Symbol (fails as expected).
- Invoking with a Symbol in the external object array (works as expected).
- Filling the external objects array with a mixed combination of junk and Semaphores; the primitive works on the semaphores but not the junk.

Tests not run:
- Trying to use the Semaphore.