[BUG] CompiledMethod>>sourceClass (was: RE: [BUG] "debug it" not working)

Andreas Raab andreas.raab at gmx.de
Wed Dec 10 01:03:42 UTC 2003


Hi Guys,

I think Doug's problem points to what may be a serious bug in the compiler
changes. The reason why debugIt fails is that before it comes to the place
where the #DoIt is executed there's another #DoIt executed which
-afterwards- removes the selector (ho hum).

What's more interesting here is what the other #DoIt (or rather: all four of
them) is indeed doing. It's coming from CompiledMethod>>sourceClass which
attempts to evaluate the source code of the method to figure out the class
it has been defined in.

*That* is obviously a Very Problematic Thing to do. If a class has ever been
renamed and the method hasn't been newly compiled (as is often the case for
simple class rename) the source code will not accurately answer the class
where the code has been defined. In the worst case, you define class Foo
with method #bar, then rename Foo to Bar, then define another class Foo and
method #bar and when you now ask Bar>>bar for its sourceClass it will
happily answer that it was defined for Foo. I have no idea what might happen
then.

What's more is that when we look at the callers of that method we can see
that the class we find in the source code is preferred over anything that is
explicitly handed in. That seems even odder to me - in almost all cases we
_do_ have the defining class along with the method (implicitly from the
context) and so typically there isn't even the theoretical need to go to a
file.

Something is very, very odd here. I really don't understand why we'd either
want or have to go to the source file for finding the defining class for
some method.

Cheers,
  - Andreas

> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org 
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On 
> Behalf Of Doug Way
> Sent: Wednesday, December 10, 2003 12:40 AM
> To: The general-purpose Squeak developers list
> Subject: [BUG] "debug it" not working
> 
> 
> 
> 1. Enter some code in a workspace (e.g. "3 factorial"), 
> highlight it and 
> select "debug it" from the menu
> 2. A code simulation error occurs.  See stack below.  (Side note: we 
> should really include the debugger titlebar text (in this case, "Code 
> simulation error") in the "mail to list" debug text.)
> 
> This happens in a fresh 5595 image, but didn't happen in a fresh 5526 
> image, so it's pretty recent.  May be related to SmaCC 
> changes, I'm not 
> sure... If it's because we're still in the middle of those changes, 
> maybe it's nothing to worry about for now.
> 
> - Doug
> 
> 
> --------------------------------------------
> 
> 9 December 2003 6:34:11 pm
> 
> VM: Win32 - Squeak3.5 of '11 April 2003' [latest update: #5180]
> Image: Squeak3.7alpha [latest update: #5595]
> 
> Project class>>spawnNewProcess
>     Receiver: Project
>     Arguments and temporary variables:
> 
>     Receiver's instance variables:
>         superclass:     Model
>         methodDict:     a MethodDictionary(#abortResourceLoading->a 
> CompiledMethod (3234) #...etc...
>         format:     172
>         instanceVariables:     #('world' 'changeSet' 'transcript' 
> 'parentProject' 'previous...etc...
>         organization:     ('initialization' 
> backgroundColorForMorphicProject backgroundColo...etc...
>         subclasses:     nil
>         name:     #Project
>         classPool:     a Dictionary(#AllProjects->an 
> OrderedCollection(a 
> Project(New Changes) a Project(The Worlds of Squeak) a 
> Project(Fun with 
> Morphic) a Project(Fun With Music) a Project(Building with Squeak) a 
> Project(Squeak and the Internet) a Project(More About Sound)) 
> #CurrentProject->a Project(New Changes) #GoalFreePercent->nil 
> #GoalNotMoreThan->nil #UIProcess->a Process in nil )...etc...
>         sharedPools:     nil
>         environment:     a SystemDictionary(lots of globals)
>         category:     nil
> 
> Project class>>spawnNewProcessIfThisIsUI:
>     Receiver: Project
>     Arguments and temporary variables:
>         suspendedProcess:     a Process in Process>>suspend
>     Receiver's instance variables:
>         superclass:     Model
>         methodDict:     a MethodDictionary(#abortResourceLoading->a 
> CompiledMethod (3234) #...etc...
>         format:     172
>         instanceVariables:     #('world' 'changeSet' 'transcript' 
> 'parentProject' 'previous...etc...
>         organization:     ('initialization' 
> backgroundColorForMorphicProject backgroundColo...etc...
>         subclasses:     nil
>         name:     #Project
>         classPool:     a Dictionary(#AllProjects->an 
> OrderedCollection(a 
> Project(New Changes) a Project(The Worlds of Squeak) a 
> Project(Fun with 
> Morphic) a Project(Fun With Music) a Project(Building with Squeak) a 
> Project(Squeak and the Internet) a Project(More About Sound)) 
> #CurrentProject->a Project(New Changes) #GoalFreePercent->nil 
> #GoalNotMoreThan->nil #UIProcess->a Process in nil )...etc...
>         sharedPools:     nil
>         environment:     a SystemDictionary(lots of globals)
>         category:     nil
> 
> CurrentProjectRefactoring class>>newProcessIfUI:
>     Receiver: CurrentProjectRefactoring
>     Arguments and temporary variables:
>         aDeadOrDyingProcess:     a Process in Process>>suspend
>     Receiver's instance variables:
>         superclass:     Object
>         methodDict:     a MethodDictionary()
>         format:     2
>         instanceVariables:     nil
>         organization:     ('as yet unclassified')
> 
>         subclasses:     nil
>         name:     #CurrentProjectRefactoring
>         classPool:     nil
>         sharedPools:     nil
>         environment:     a SystemDictionary(lots of globals)
>         category:     nil
> 
> Debugger class>>openOn:context:label:contents:fullView:
>     Receiver: Debugger
>     Arguments and temporary variables:
>         process:     a Process in Process>>suspend
>         context:     UndefinedObject(Object)>>doesNotUnderstand: #DoIt
>         title:     'MessageNotUnderstood: nil>>DoIt'
>         contentsStringOrNil:     nil
>         bool:     false
>         controller:     nil
>         errorWasInUIProcess:     nil
>         debugger:     nil
>         ex:     nil
>     Receiver's instance variables:
>         superclass:     CodeHolder
>         methodDict:     a MethodDictionary(#abandon->a CompiledMethod 
> (3303) #abandon:->a C...etc...
>         format:     176
>         instanceVariables:     #('interruptedProcess' 
> 'interruptedController' 'contextStack...etc...
>         organization:     ('initialize' 
> buildMVCDebuggerViewLabel:minSize: buildMVCNotifier...etc...
>         subclasses:     nil
>         name:     #Debugger
>         classPool:     a Dictionary(#ContextStackKeystrokes->a 
> Dictionary($T->#stepIntoBloc...etc...
>         sharedPools:     nil
>         environment:     a SystemDictionary(lots of globals)
>         category:     nil
> 
> 
> --- The full stack ---
> Project class>>spawnNewProcess
> Project class>>spawnNewProcessIfThisIsUI:
> CurrentProjectRefactoring class>>newProcessIfUI:
> Debugger class>>openOn:context:label:contents:fullView:
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Process>>debug:title:full:
> Process>>debug:title:
> UnhandledError>>devDefaultAction
> UnhandledError>>defaultAction
> UndefinedObject>>handleSignal:
> UnhandledError(Exception)>>signal
> UnhandledError class>>signalForException:
> MessageNotUnderstood(Error)>>defaultAction
> UndefinedObject>>handleSignal:
> MessageNotUnderstood(Exception)>>signal
> ...etc...
> 
> 
> 




More information about the Squeak-dev mailing list