[Pharo-project] Problem with CompiledMethodTrailer

Mariano Martinez Peck marianopeck at gmail.com
Mon May 9 15:27:41 CEST 2011


Ok, the problem is the following. Check my screenshot of the previous mail.
Left is incorrect, right is correct.
As you can notice, the "correct" CompiledMethod finishes with a bytecode
"return self" and number 78. This bytecode is missing in the "incorrect" CM.
And, the first byte in method trailer in the incorrect CM is 120. Guess
what?  16r78 -> 120.  So...the incorrect CM interpret that byte as trailer
instead of bytecode.
Now, if you ask to the incorrect CM: "trailer data", you get, of course,
120.

If you see

sourcePointer: ptr

    self clear.
    data := ptr.
    "see if we can encode pointer using 4-byte trailer"
    kind := (ptr between: 16r1000000 and: 16r4FFFFFF)
        ifTrue: [ #SourcePointer ] ifFalse: [ #VarLengthSourcePointer ].


You can guess that ptr is 120, hence it sets #VarLengthSourcePointer

Now...two problem bugs:

1) how can these CM be generated????  Compiler bug?

2) where are they kept that I cannot garbage collect them ??

Cheers

Mariano


On Mon, May 9, 2011 at 2:50 PM, Mariano Martinez Peck <marianopeck at gmail.com
> wrote:

>
>
> On Mon, May 9, 2011 at 12:48 PM, Igor Stasenko <siguctua at gmail.com> wrote:
>
>> the one to the left seems like broken. it not ends with return self.
>>
>>
> yes, exactly. That one on the left is the one that  trailer kind answers
> #VarLengthSourcePointer
> the right is the correct one.
>
> You can also notice that the one of the left in addition to not having the
> last bytecode (self return), it has only 2 bytes for the trailer.
>
> Anyway, regardless of how such CM could have been generated, I CANNOT find
> who is pointing to them. They appear only in PharoDev and I cannot find any
> pattern between them :(
>
> :(
>
>  On 9 May 2011 11:22, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
>> >
>> >
>> > On Mon, May 9, 2011 at 10:53 AM, Mariano Martinez Peck
>> > <marianopeck at gmail.com> wrote:
>> >>
>> >>
>> >> On Mon, May 9, 2011 at 10:27 AM, Nicolas Cellier
>> >> <nicolas.cellier.aka.nice at gmail.com> wrote:
>> >>>
>> >>> Hi Mariano,
>> >>> you should try these two things before repeating yourself:
>> >>>
>> >>> (CompiledMethod allInstances select:  [:each | each trailer kind =
>> >>> #VarLengthSourcePointer] ) first trailer kind.
>> >>>
>> >>> | temp |
>> >>> temp := (CompiledMethod allInstances select:  [:each | each trailer
>> >>> kind = #VarLengthSourcePointer] ) first.
>> >>> temp == (temp methodClass >> temp selector)
>> >>>
>> >>
>> >> Thanks Nicolas. Yes,  in fact all of you were right. They are not the
>> same
>> >> CM instance. They are different.
>> >> It is wierd that they are only present in Pharo1.3:
>> >>
>> >>
>> >> ((CompiledMethod allInstances select:  [:each | each trailer kind =
>> >> #VarLengthSourcePointer] ) ) size
>> >> ->>>   11
>> >>
>> >> And in Pharo 1.2, cero and and 1.1.1, 2.
>> >>
>> >> I am trying to inspect pointers to them to see who is pointing to
>> >> them...but I cannot find anything :(
>> >>
>> >> I will continue....
>> >>
>> >
>> > More data: there are only these kind of compiled methods in the dev
>> image.
>> > Not in core.
>> >
>> > In addition, if I do: ScriptLoader new cleanUpForRelease, then inspect
>> > ((CompiledMethod allInstances select:  [:each | each trailer kind =
>> > #VarLengthSourcePointer] ) )
>> >
>> > and then I click on the first element in the inspector.... VM CRASH!!!
>> with
>> > both, InterpreterVM and CogVM.
>> >
>> > I can see the difference in the trailer of the CMs (I attach
>> screenshot),
>> > but still cannot find who is pointing to that weird instances :(
>> >
>> > grrr... thanks for the help
>> >
>> >
>> >
>> >>
>> >> thanks
>> >>
>> >>
>> >>
>> >>> It may be possible that CompiledMethod>>printString is lying to you...
>> >>>
>> >>> Nicolas
>> >>>
>> >>> 2011/5/9 Mariano Martinez Peck <marianopeck at gmail.com>:
>> >>> >
>> >>> >
>> >>> > On Mon, May 9, 2011 at 6:14 AM, Igor Stasenko <siguctua at gmail.com>
>> >>> > wrote:
>> >>> >>
>> >>> >> On 9 May 2011 00:52, Mariano Martinez Peck <marianopeck at gmail.com>
>> >>> >> wrote:
>> >>> >> > Hi guys, Maybe it is too late and I am not seeing something
>> >>> >> > obvious...so
>> >>> >> > another look is really appreciated. If I do:
>> >>> >> >
>> >>> >> > (CompiledMethod allInstances select:  [:each | each trailer kind
>> =
>> >>> >> > #VarLengthSourcePointer] ) first
>> >>> >> > ---> (CodeLoader class>>#initialize "a
>> CompiledMethod(311951360)")
>> >>> >> >
>> >>> >> > But then:
>> >>> >> >
>> >>> >> > (CodeLoader class >> #initialize) trailer kind
>> >>> >> > ----> #SourcePointer
>> >>> >> >
>> >>> >> > WHYYY??  why it is answering #SourcePointer instead of
>> >>> >> > #VarLengthSourcePointer  ??
>> >>> >> >
>> >>> >> > grrr how can that be possible???  It happens the same to each of
>> the
>> >>> >> > CompiledMethods I select as #VarLengthSourcePointer.  When I then
>> >>> >> > ask
>> >>> >> > the
>> >>> >> > #kind  they always answer #SourcePointer  instead of
>> >>> >> > #VarLengthSourcePointer
>> >>> >> >
>> >>> >> is it same compiled methods?
>> >>> >> Because it is absolutely normal if they using different source
>> >>> >> pointer.
>> >>> >>
>> >>> >
>> >>> > I didn't understand your question. Yes, it is exactly the same
>> >>> > CompiledMethod.
>> >>> > Look, if I do:
>> >>> >
>> >>> > (CompiledMethod allInstances select:  [:each | each trailer kind =
>> >>> > #VarLengthSourcePointer] ) first
>> >>> >
>> >>> > I get
>> >>> > ---> (CodeLoader class>>#initialize "a CompiledMethod(311951360)")
>> >>> >
>> >>> > So...it means that such CompiledMethod answers
>> #VarLengthSourcePointer
>> >>> > when
>> >>> > send "trailer kind". Ok?
>> >>> >
>> >>> > But immediatly after, if I ask the trailer kind to the SAME compiled
>> >>> > method:
>> >>> >
>> >>> > (CodeLoader class >> #initialize) trailer kind
>> >>> >
>> >>> > I get
>> >>> > ----> #SourcePointer
>> >>> >
>> >>> > WHYYY??  why it is answering #SourcePointer instead of
>> >>> > #VarLengthSourcePointer  ??
>> >>> >
>> >>> >>
>> >>> >> > thanks in advance,
>> >>> >> >
>> >>> >> > --
>> >>> >> > Mariano
>> >>> >> > http://marianopeck.wordpress.com
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> --
>> >>> >> Best regards,
>> >>> >> Igor Stasenko AKA sig.
>> >>> >>
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Mariano
>> >>> > http://marianopeck.wordpress.com
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Mariano
>> >> http://marianopeck.wordpress.com
>> >>
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110509/40a0e8a8/attachment.htm>


More information about the Pharo-project mailing list