[squeak-dev] renaming a class causes invalid super pointer CompiledMethod..!

Chris Muller asqueaker at gmail.com
Wed Jan 21 19:34:36 UTC 2015


Okay, I got it.  It's not the rename, the reason it worked was because
it was not an instance of a further subclass.  As demonstrated by [1].

DoIt processing calculates "super" of the receiver's class, not the
methodHome's class.  Just what you said.

As far as everyday debugging, I've never noticed this behavior in 21
years of Smalltalking.  When I was debugging yesterday and the code of
my superclass method was one-line "^true" and I got false back --- it
was surreal.

Well found indeed, thanks for fixing.

[1] -- Same script but instantiate MySubclass (under MyClass) instead.

Object compile: 'test  ^''Hello from Object'''.
(Object subclass: #MyClass instanceVariableNames: ''
classVariableNames: '' poolDictionaries: '' category: 'Test') compile:
'test  self halt.  ^ super test, ''my super call lands on myself!'''.
((Smalltalk classNamed: #MyClass) subclass: #MySubclass
instanceVariableNames: ''
classVariableNames: '' poolDictionaries: '' category: 'Test').
(Smalltalk classNamed: #MySubclass) new test

On Wed, Jan 21, 2015 at 1:20 PM, Chris Muller <asqueaker at gmail.com> wrote:
> On Wed, Jan 21, 2015 at 12:24 PM, Tobias Pape <Das.Linux at gmx.de> wrote:
>> Hi Chris
>>
>> On 21.01.2015, at 17:39, Chris Muller <asqueaker at gmail.com> wrote:
>>
>>> Okay, I found the invalid super-pointer behavior.
>>>
>>> It's a lot better with Bert & Tobias' fix, but still there to a smaller degree..
>>>
>>> Object compile: 'test  ^''Hello from Object'''.
>>> (Object subclass: #MyClass instanceVariableNames: ''
>>> classVariableNames: '' poolDictionaries: '' category: 'Test') compile:
>>> 'test  self halt.  ^ super test, ''my super call lands on myself!'''.
>>> (Smalltalk classNamed: #MyClass) rename: 'MyNewAbstraction'.
>>> ((Smalltalk classNamed: #MyNewAbstraction) subclass: #MyClass
>>> instanceVariableNames: '' classVariableNames: '' poolDictionaries: ''
>>> category: 'Test').
>>> (Smalltalk classNamed: #MyClass) new test
>>>
>>> Do-it on the above.  When the debugger appears, simply highlight the
>>> code "super test" in the debugger and press "Print It".
>>>
>>> I expected to see 'Hello from Object' but it seems to be calculating
>>> super from the receiver class rather than the method's home class...
>>>
>>> WITHOUT Bert and Tobias' fix, the above results in the super call
>>> truly landing on itself, and if you take the halt out, the
>>> tight-recursion I mentioned from teh first paragraph of this thread.
>>> WITH their fix, the problem only manifests in the debugger as
>>> demonstrated.
>>
>> If you hit step-into, you actually end up in the Superclass.
>> _Only_ if you select 'super test' and PrintIt (or DoIt), the
>> apparent “recursion” is triggered.
>>   This is due to the way DoIt work, they compile an anonymous class
>> that are “homed” in the receivers class, in this case MyClass. Hence,
>> super ends up in MyNewAbstraction[1].
>>   Yes, this is a bit surprising, but I don't know whether it is wrong.
>
> It is inconsistent than if you did not do the rename:
>
> Object compile: 'test  ^''Hello from Object'''.
> (Object subclass: #MyClass instanceVariableNames: ''
> classVariableNames: '' poolDictionaries: '' category: 'Test') compile:
> 'test  self halt.  ^ super test, ''my super call lands on myself!'''.
> (Smalltalk classNamed: #MyClass) new test
>
> This time, inside the debugger, "super test" reports the expected
> 'Hello from Object'.
>
> So, _something_ must be different in the renamed class..?
>
>
>
>>
>>
>> Compiler>>evaluate:in:to:notifying:ifFail:logged:
>>
>> calculates the home class of the DoIt via this:
>>
>>         | theClass |
>>         theClass := ((aContext == nil ifTrue: [receiver] ifFalse: [aContext receiver]) class).
>>
>> that is, the _Receiver_ of the context, not the home class of the context's method.
>>
>> @Bert, Eliot: Which one do you think would be correct? the Stack is down below[1].
>>
>>
>>
>> Best
>>         -Tobias
>>
>>
>> [1]:
>>
>> Compiler>>evaluateCue:ifFail:
>>         Receiver: a Compiler
>>         Arguments and temporary variables:
>>                 aCue:   a CompilationCue
>>                 failBlock:      [closure] in Compiler>>evaluateCue:ifFail:logged:
>>                 methodNode:     DoItIn: ThisContext
>>         ^ super test
>>                 method:         (MyClass>>#DoItIn: "a CompiledMethod(374)")
>>                 value:  nil
>>         Receiver's instance variables:
>>                 parser:         a Parser
>>                 cue:    a CompilationCue
>>
>> Compiler>>evaluateCue:ifFail:logged:
>>         Receiver: a Compiler
>>         Arguments and temporary variables:
>>                 aCue:   a CompilationCue
>>                 failBlock:      [closure] in [] in SmalltalkEditor(TextEditor)>>evaluateSelectionAnd...etc...
>>                 logFlag:        true
>>                 value:  nil
>>         Receiver's instance variables:
>>                 parser:         a Parser
>>                 cue:    a CompilationCue
>>
>> Compiler>>evaluate:in:to:notifying:ifFail:logged:
>>         Receiver: a Compiler
>>         Arguments and temporary variables:
>>                 textOrStream:   a ReadStream
>>                 aContext:       MyClass(MyNewAbstraction)>>test
>>                 receiver:       a MyClass
>>                 aRequestor:     a SmalltalkEditor
>>                 failBlock:      [closure] in [] in SmalltalkEditor(TextEditor)>>evaluateSelectionAnd...etc...
>>                 logFlag:        true
>>                 theClass:       MyClass
>>         Receiver's instance variables:
>>                 parser:         a Parser
>>                 cue:    a CompilationCue
>>
>> [] in SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>>         Receiver: a SmalltalkEditor
>>         Arguments and temporary variables:
>> <<error during printing>
>>         Receiver's instance variables:
>>                 morph:  a TextMorphForEditView(3464)
>>                 selectionShowing:       false
>>                 model:  a Debugger
>>                 paragraph:      a NewParagraph
>>                 markBlock:      a CharacterBlock with index 21 and character $s and rectangle 110 at 0 ...etc...
>>                 pointBlock:     a CharacterBlock with index 31 and character $, and rectangle 174 at 0...etc...
>>                 beginTypeInIndex:       nil
>>                 emphasisHere:   {a TextColor code: (Color r: 0.0 g: 0.0 b: 0.5)}
>>                 lastParenLocation:      nil
>>                 otherInterval:  (20 to: 19)
>>                 oldInterval:    (20 to: 19)
>>                 typeAhead:      nil
>>                 styler:         nil
>>
>> BlockClosure>>on:do:
>>         Receiver: [closure] in SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>>         Arguments and temporary variables:
>>                 exception:      OutOfScopeNotification
>>                 handlerAction:  [closure] in SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo...etc...
>>                 handlerActive:  true
>>         Receiver's instance variables:
>>                 outerContext:   SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>>                 startpc:        97
>>                 numArgs:        0
>>
>> SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>>         Receiver: a SmalltalkEditor
>>         Arguments and temporary variables:
>>                 aBlock:         [closure] in [] in PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>>                 result:         nil
>>                 rcvr:   a MyClass
>>                 ctxt:   MyClass(MyNewAbstraction)>>test
>>         Receiver's instance variables:
>>                 morph:  a TextMorphForEditView(3464)
>>                 selectionShowing:       false
>>                 model:  a Debugger
>>                 paragraph:      a NewParagraph
>>                 markBlock:      a CharacterBlock with index 21 and character $s and rectangle 110 at 0 ...etc...
>>                 pointBlock:     a CharacterBlock with index 31 and character $, and rectangle 174 at 0...etc...
>>                 beginTypeInIndex:       nil
>>                 emphasisHere:   {a TextColor code: (Color r: 0.0 g: 0.0 b: 0.5)}
>>                 lastParenLocation:      nil
>>                 otherInterval:  (20 to: 19)
>>                 oldInterval:    (20 to: 19)
>>                 typeAhead:      nil
>>                 styler:         nil
>>
>> [] in PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>>         Receiver: a PluggableTextMorphPlus(473)
>>         Arguments and temporary variables:
>>                 oldEditor:      {a SmalltalkEditor}
>>         Receiver's instance variables:
>>                 bounds:         36 at 380 corner: 740 at 592
>>                 owner:  a PluggablePanelMorph(3130)
>>                 submorphs:      {a ScrollBar(1013) . a TransformMorph(3047)}
>>                 fullBounds:     36 at 380 corner: 740 at 592
>>                 color:  Color white
>>                 extension:      a MorphExtension (3891) [other:  (layoutFrame -> a LayoutFrame) (vSc...etc...
>>                 borderWidth:    1
>>                 borderColor:    Color lightGray
>>                 model:  a Debugger
>>                 slotName:       nil
>>                 open:   false
>>                 scrollBar:      a ScrollBar(1013)
>>                 scroller:       a TransformMorph(3047)
>>                 retractableScrollBar:   false
>>                 scrollBarOnLeft:        false
>>                 getMenuSelector:        #codePaneMenu:shifted:
>>                 getMenuTitleSelector:   nil
>>                 scrollBarHidden:        nil
>>                 hasFocus:       false
>>                 hScrollBar:     a ScrollBar(2030)
>>                 textMorph:      a TextMorphForEditView(3464)
>>                 getTextSelector:        #contents
>>                 setTextSelector:        #contents:notifying:
>>                 getSelectionSelector:   #contentsSelection
>>                 hasUnacceptedEdits:     false
>>                 askBeforeDiscardingEdits:       true
>>                 selectionInterval:      (21 to: 30)
>>                 hasEditingConflicts:    false
>>                 getColorSelector:       nil
>>                 acceptAction:   nil
>>                 unstyledAcceptText:     nil
>>                 styler:         a SHTextStylerST80
>>
>> TextMorphForEditView(TextMorph)>>handleEdit:
>>         Receiver: a TextMorphForEditView(3464)
>>         Arguments and temporary variables:
>>                 editBlock:      [closure] in PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>>                 result:         nil
>>         Receiver's instance variables:
>>                 bounds:         0 at 0 corner: 683 at 18
>>                 owner:  a TransformMorph(3047)
>>                 submorphs:      #()
>>                 fullBounds:     0 at 0 corner: 683 at 18
>>                 color:  Color black
>>                 extension:      a MorphExtension (3814) [other:  (blinkStart -> 1091554)]
>>                 borderWidth:    0
>>                 borderColor:    Color black
>>                 textStyle:      a TextStyle Bitmap DejaVu Sans 9
>>                 text:   a Text for 'test  self halt.  ^ super test, ''my super call lands on myse...etc...
>>                 wrapFlag:       true
>>                 paragraph:      a NewParagraph
>>                 editor:         a SmalltalkEditor
>>                 container:      nil
>>                 predecessor:    nil
>>                 successor:      nil
>>                 backgroundColor:        nil
>>                 margins:        nil
>>                 editHistory:    nil
>>                 editView:       a PluggableTextMorphPlus(473)
>>                 acceptOnCR:     false
>>
>> PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>>         Receiver: a PluggableTextMorphPlus(473)
>>         Arguments and temporary variables:
>>                 oldEditor:      {a SmalltalkEditor}
>>         Receiver's instance variables:
>>                 bounds:         36 at 380 corner: 740 at 592
>>                 owner:  a PluggablePanelMorph(3130)
>>                 submorphs:      {a ScrollBar(1013) . a TransformMorph(3047)}
>>                 fullBounds:     36 at 380 corner: 740 at 592
>>                 color:  Color white
>>                 extension:      a MorphExtension (3891) [other:  (layoutFrame -> a LayoutFrame) (vSc...etc...
>>                 borderWidth:    1
>>                 borderColor:    Color lightGray
>>                 model:  a Debugger
>>                 slotName:       nil
>>                 open:   false
>>                 scrollBar:      a ScrollBar(1013)
>>                 scroller:       a TransformMorph(3047)
>>                 retractableScrollBar:   false
>>                 scrollBarOnLeft:        false
>>                 getMenuSelector:        #codePaneMenu:shifted:
>>                 getMenuTitleSelector:   nil
>>                 scrollBarHidden:        nil
>>                 hasFocus:       false
>>                 hScrollBar:     a ScrollBar(2030)
>>                 textMorph:      a TextMorphForEditView(3464)
>>                 getTextSelector:        #contents
>>                 setTextSelector:        #contents:notifying:
>>                 getSelectionSelector:   #contentsSelection
>>                 hasUnacceptedEdits:     false
>>                 askBeforeDiscardingEdits:       true
>>                 selectionInterval:      (21 to: 30)
>>                 hasEditingConflicts:    false
>>                 getColorSelector:       nil
>>                 acceptAction:   nil
>>                 unstyledAcceptText:     nil
>>                 styler:         a SHTextStylerST80
>>
>> Debugger(StringHolder)>>perform:orSendTo:
>>         Receiver: a Debugger
>>         Arguments and temporary variables:
>>                 selector:       #printIt
>>                 otherTarget:    a PluggableTextMorphPlus(473)
>>         Receiver's instance variables:
>>                 dependents:     a DependentsArray(a PluggableSystemWindow(1857) a PluggableListMorp...etc...
>>                 contents:       a Text for 'test  self halt.  ^ super test, ''my super call lands on ...etc...
>>                 currentCompiledMethod:  nil
>>                 contentsSymbol:         #source
>>                 multiWindowState:       nil
>>                 interruptedProcess:     a Process in Debugger class>>morphicOpenOn:context:label:co...etc...
>>                 interruptedController:  nil
>>                 contextStack:   an OrderedCollection(MyClass(Object)>>halt MyClass(MyNewAbstracti...etc...
>>                 contextStackIndex:      2
>>                 contextStackList:       an OrderedCollection('MyClass(Object)>>halt' 'MyClass(MyNewAb...etc...
>>                 receiverInspector:      an Inspector
>>                 contextVariablesInspector:      a ContextVariablesInspector
>>                 externalInterrupt:      false
>>                 proceedValue:   nil
>>                 selectingPC:    true
>>                 savedCursor:    ((CursorWithMask
>>         extent: 16 at 16
>>         depth: 1
>>         fromArray: #(
>>                 2r0
>>                 2...etc...
>>                 isolationHead:  nil
>>                 failedProject:  nil
>>                 errorWasInUIProcess:    true
>>                 labelString:    nil
>>                 message:        nil
>>                 untilExpression:        nil
>>
>> Debugger>>perform:orSendTo:
>>         Receiver: a Debugger
>>         Arguments and temporary variables:
>>                 selector:       #printIt
>>                 otherTarget:    a PluggableTextMorphPlus(473)
>>                 result:         nil
>>         Receiver's instance variables:
>>                 dependents:     a DependentsArray(a PluggableSystemWindow(1857) a PluggableListMorp...etc...
>>                 contents:       a Text for 'test  self halt.  ^ super test, ''my super call lands on ...etc...
>>                 currentCompiledMethod:  nil
>>                 contentsSymbol:         #source
>>                 multiWindowState:       nil
>>                 interruptedProcess:     a Process in Debugger class>>morphicOpenOn:context:label:co...etc...
>>                 interruptedController:  nil
>>                 contextStack:   an OrderedCollection(MyClass(Object)>>halt MyClass(MyNewAbstracti...etc...
>>                 contextStackIndex:      2
>>                 contextStackList:       an OrderedCollection('MyClass(Object)>>halt' 'MyClass(MyNewAb...etc...
>>                 receiverInspector:      an Inspector
>>                 contextVariablesInspector:      a ContextVariablesInspector
>>                 externalInterrupt:      false
>>                 proceedValue:   nil
>>                 selectingPC:    true
>>                 savedCursor:    ((CursorWithMask
>>         extent: 16 at 16
>>         depth: 1
>>         fromArray: #(
>>                 2r0
>>                 2...etc...
>>                 isolationHead:  nil
>>                 failedProject:  nil
>>                 errorWasInUIProcess:    true
>>                 labelString:    nil
>>                 message:        nil
>>                 untilExpression:        nil
>>
>> MenuItemMorph>>DoIt
>>         Receiver: a MenuItemMorph(77)'print it (p)'
>>         Arguments and temporary variables:
>>
>>         Receiver's instance variables:
>>                 bounds:         216 at 558 corner: 359 at 576
>>                 owner:  a MenuMorph(2209)
>>                 submorphs:      #()
>>                 fullBounds:     216 at 558 corner: 359 at 576
>>                 color:  Color black
>>                 extension:      a MorphExtension (264) [other:  (layoutProperties -> a LayoutPropert...etc...
>>                 font:   a StrikeFont(Bitmap DejaVu Sans 9 14)
>>                 emphasis:       0
>>                 contents:       'print it (p)'
>>                 hasFocus:       false
>>                 isEnabled:      true
>>                 subMenu:        nil
>>                 isSelected:     false
>>                 target:         a Debugger
>>                 selector:       #perform:orSendTo:
>>                 arguments:      {#printIt . a PluggableTextMorphPlus(473)}
>>                 icon:   Form(16x16x32)
>>                 lastMousePosition:      nil
>>
>> CompiledMethod>>valueWithReceiver:arguments:
>>         Receiver: (MenuItemMorph>>#DoIt "a CompiledMethod(1420)")
>>         Arguments and temporary variables:
>>                 aReceiver:      a MenuItemMorph(77)'print it (p)'
>>                 anArray:        #()
>>         Receiver's instance variables:
>> (MenuItemMorph>>#DoIt "a CompiledMethod(1420)")
>>
>> [] in SmalltalkEditor(TextEditor)>>debug:receiver:in:
>>         Receiver: a SmalltalkEditor
>>         Arguments and temporary variables:
>> <<error during printing>
>>         Receiver's instance variables:
>>                 morph:  a TextMorphForEditView(4064)
>>                 selectionShowing:       false
>>                 model:  an ObjectExplorer
>>                 paragraph:      a NewParagraph
>>                 markBlock:      a CharacterBlock with index 1 and character $s and rectangle 0 at 0 cor...etc...
>>                 pointBlock:     a CharacterBlock with index 62 and rectangle 366 at 0 corner: 366 at 16
>>  ...etc...
>>                 beginTypeInIndex:       nil
>>                 emphasisHere:   {a TextFontChange font: 2}
>>                 lastParenLocation:      nil
>>                 otherInterval:  (61 to: 61)
>>                 oldInterval:    (55 to: 54)
>>                 typeAhead:      a WriteStream
>>                 styler:         nil
>>
>> [] in BlockClosure>>newProcess
>>         Receiver: [closure] in SmalltalkEditor(TextEditor)>>debug:receiver:in:
>>         Arguments and temporary variables:
>>
>>         Receiver's instance variables:
>>                 outerContext:   SmalltalkEditor(TextEditor)>>debug:receiver:in:
>>                 startpc:        112
>>                 numArgs:        0
>>
>>
>> --- The full stack ---
>> Compiler>>evaluateCue:ifFail:
>> Compiler>>evaluateCue:ifFail:logged:
>> Compiler>>evaluate:in:to:notifying:ifFail:logged:
>> [] in SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>> BlockClosure>>on:do:
>> SmalltalkEditor(TextEditor)>>evaluateSelectionAndDo:
>> [] in PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>> TextMorphForEditView(TextMorph)>>handleEdit:
>> PluggableTextMorphPlus(PluggableTextMorph)>>printIt
>> Debugger(StringHolder)>>perform:orSendTo:
>> Debugger>>perform:orSendTo:
>> MenuItemMorph>>DoIt
>> CompiledMethod>>valueWithReceiver:arguments:
>> [] in SmalltalkEditor(TextEditor)>>debug:receiver:in:
>> [] in BlockClosure>>newProcess
>>
>>
>>
>>


More information about the Squeak-dev mailing list