[Cog] reproducable crash with SmallInteger as methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Cog] reproducable crash with SmallInteger as methods

Mariano Martinez Peck
 
Hi Eliot. Today I can reproduce a do-it that crash Cog, when using SmallIntegers as compiled methods. The problem is actually that IT ONLY crashes when compiling in XCode with "Development". However, if I compile with "Deployment", it doesn't crash....

The code is this:

SmallInteger compile: 'flushCache "emtpy"'.
SmallInteger compile: 'run: aSelector with: arguments in: aReceiver
    Transcript show: ''something''.'.
TestCase compile: 'foo  ^ ''foo'' '.

TestCase methodDict at: #foo put: 5.
TestCase new foo. 


I really don't understand how this can work in "Deployment" but not in "Development" since the code is the same as I know. Maybe when debugging certain functions/methods are called that crash?

Thanks for any tip.

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: [Cog] reproducable crash with SmallInteger as methods

Mariano Martinez Peck
 
Hi Eliot. I "fix/patch" it by chaging primitiveIndexOf:   to this:

primitiveIndexOf: methodPointer
    "Note: We now have 10 bits of primitive index, but they are in two places
    for temporary backward compatibility.  The time to unpack is negligible,
     since the derived primitive function pointer is stored in the method cache."
    <api>
    | primBits |
   
    (objectMemory isOopCompiledMethod: methodPointer)
        ifTrue:
            [primBits := ((self headerOf: methodPointer) >> 1) bitAnd: 16r100001FF.
            ^(primBits bitAnd: 16r1FF) + (primBits >> 19)]
        ifFalse:
            [^ 0 ].


at least for my case, it patches the problem. Still, I have no idea:

- the implicance/side effect of this change
- why in development was crashing but not in deployment.

thanks

mariano


On Thu, Dec 16, 2010 at 5:27 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. Today I can reproduce a do-it that crash Cog, when using SmallIntegers as compiled methods. The problem is actually that IT ONLY crashes when compiling in XCode with "Development". However, if I compile with "Deployment", it doesn't crash....

The code is this:

SmallInteger compile: 'flushCache "emtpy"'.
SmallInteger compile: 'run: aSelector with: arguments in: aReceiver
    Transcript show: ''something''.'.
TestCase compile: 'foo  ^ ''foo'' '.

TestCase methodDict at: #foo put: 5.
TestCase new foo. 


I really don't understand how this can work in "Deployment" but not in "Development" since the code is the same as I know. Maybe when debugging certain functions/methods are called that crash?

Thanks for any tip.

Mariano

Reply | Threaded
Open this post in threaded view
|

Re: [Cog] reproducable crash with SmallInteger as methods

Mariano Martinez Peck
 
And this change in  #primitiveIndexOf:
also fixes the #flushCache in SmallInteger.

Because if you use SmallInteger as methods, you need to implement #flushCache because it is used in MethodDIctionary >> #at:put:
But before this change, this crashes because of the send to #primitiveIndexOf:
But since now #primitiveIndexOf: is working, #primitiveFlushCacheByMethod  doesn't fail anymore with SmallInteger  :)


Cheers

Mariano

On Fri, Dec 17, 2010 at 11:01 AM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. I "fix/patch" it by chaging primitiveIndexOf:   to this:

primitiveIndexOf: methodPointer
    "Note: We now have 10 bits of primitive index, but they are in two places
    for temporary backward compatibility.  The time to unpack is negligible,
     since the derived primitive function pointer is stored in the method cache."
    <api>
    | primBits |
   
    (objectMemory isOopCompiledMethod: methodPointer)
        ifTrue:
            [primBits := ((self headerOf: methodPointer) >> 1) bitAnd: 16r100001FF.
            ^(primBits bitAnd: 16r1FF) + (primBits >> 19)]
        ifFalse:
            [^ 0 ].


at least for my case, it patches the problem. Still, I have no idea:

- the implicance/side effect of this change
- why in development was crashing but not in deployment.

thanks

mariano



On Thu, Dec 16, 2010 at 5:27 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. Today I can reproduce a do-it that crash Cog, when using SmallIntegers as compiled methods. The problem is actually that IT ONLY crashes when compiling in XCode with "Development". However, if I compile with "Deployment", it doesn't crash....

The code is this:

SmallInteger compile: 'flushCache "emtpy"'.
SmallInteger compile: 'run: aSelector with: arguments in: aReceiver
    Transcript show: ''something''.'.
TestCase compile: 'foo  ^ ''foo'' '.

TestCase methodDict at: #foo put: 5.
TestCase new foo. 


I really don't understand how this can work in "Deployment" but not in "Development" since the code is the same as I know. Maybe when debugging certain functions/methods are called that crash?

Thanks for any tip.

Mariano


Reply | Threaded
Open this post in threaded view
|

Re: [Cog] reproducable crash with SmallInteger as methods

Mariano Martinez Peck
 
Sorry, I forgot to say that fixing this is important because otherwise you have random crashes/errors because when using SmallIntegers as compiled methods, they ARE put in the cache....however, when trying to flush, it crash. So, it is important if you want to support SmallInetger as methods.

Cheers

Mariano

On Fri, Dec 17, 2010 at 6:54 PM, Mariano Martinez Peck <[hidden email]> wrote:
And this change in  #primitiveIndexOf:
also fixes the #flushCache in SmallInteger.

Because if you use SmallInteger as methods, you need to implement #flushCache because it is used in MethodDIctionary >> #at:put:
But before this change, this crashes because of the send to #primitiveIndexOf:
But since now #primitiveIndexOf: is working, #primitiveFlushCacheByMethod  doesn't fail anymore with SmallInteger  :)


Cheers

Mariano


On Fri, Dec 17, 2010 at 11:01 AM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. I "fix/patch" it by chaging primitiveIndexOf:   to this:

primitiveIndexOf: methodPointer
    "Note: We now have 10 bits of primitive index, but they are in two places
    for temporary backward compatibility.  The time to unpack is negligible,
     since the derived primitive function pointer is stored in the method cache."
    <api>
    | primBits |
   
    (objectMemory isOopCompiledMethod: methodPointer)
        ifTrue:
            [primBits := ((self headerOf: methodPointer) >> 1) bitAnd: 16r100001FF.
            ^(primBits bitAnd: 16r1FF) + (primBits >> 19)]
        ifFalse:
            [^ 0 ].


at least for my case, it patches the problem. Still, I have no idea:

- the implicance/side effect of this change
- why in development was crashing but not in deployment.

thanks

mariano



On Thu, Dec 16, 2010 at 5:27 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. Today I can reproduce a do-it that crash Cog, when using SmallIntegers as compiled methods. The problem is actually that IT ONLY crashes when compiling in XCode with "Development". However, if I compile with "Deployment", it doesn't crash....

The code is this:

SmallInteger compile: 'flushCache "emtpy"'.
SmallInteger compile: 'run: aSelector with: arguments in: aReceiver
    Transcript show: ''something''.'.
TestCase compile: 'foo  ^ ''foo'' '.

TestCase methodDict at: #foo put: 5.
TestCase new foo. 


I really don't understand how this can work in "Deployment" but not in "Development" since the code is the same as I know. Maybe when debugging certain functions/methods are called that crash?

Thanks for any tip.

Mariano