[Vm-dev] Cog on Mac. Problems with mprotect()?

Igor Stasenko siguctua at gmail.com
Tue Dec 14 15:56:05 UTC 2010


On 14 December 2010 11:58, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
>
> Hi Igor. I think I have a similar/same problem. I tried what you suggested about changing interpreterAllocationReserveBytes
>
This fixes nothing , actually.
It was crashed in pow() function , because i called thing without
properly aligning the stack.
So, forget about this change :)

> I think it now doesn't crash because of that (I think), but the message
>
> mprotect(x,y,PROT_READ | PROT_WRITE | PROT_EXEC): Cannot allocate memory
> mprotect(x,y,PROT_READ | PROT_WRITE): Invalid argument
>
> is still present. As far as I understood you said your crash was not due to that...but anyway, is that really a problem? is it fixed somewhere?
> because I am having weird crashes and I cannot discover why.
>

In NB-enabled VM it works as expected (memory code execution is
enabled) , which means that mprotect() works,
despite it barfs with errors.
I tried to play with arguments to get rid of this barfing, but without success.


> thanks
>
> mariano
>
> 2010/12/6 Igor Stasenko <siguctua at gmail.com>
>>
>> OK, i changed
>>
>> interpreterAllocationReserveBytes
>>        | availableBytesPerPage maxFramesPerPage |
>>        availableBytesPerPage := self stackPageByteSize - self
>> stackLimitOffset - self stackPageHeadroom.
>>        maxFramesPerPage := availableBytesPerPage / BytesPerWord // MFrameSlots.
>>        ^2 raisedTo: (maxFramesPerPage * LargeContextSize * numStackPages) highBit
>>
>> to:
>>
>> interpreterAllocationReserveBytes
>>        | availableBytesPerPage maxFramesPerPage |
>>        availableBytesPerPage := self stackPageByteSize - self
>> stackLimitOffset - self stackPageHeadroom.
>>        maxFramesPerPage := availableBytesPerPage / BytesPerWord // MFrameSlots.
>>        ^2 << ((maxFramesPerPage * LargeContextSize * numStackPages) highBit -1)
>>
>>
>> which is equal, except that latter its not using pow() function and
>> somehow this no longer crashing the VM.
>> The only conclusion i can make that this is really have nothing to do
>> with mprotect() and other mmap() stuff.
>>
>> I can only guess, that xcode doing some aggressive optimization,
>> violating calling conventions, or in some other way the fullGC is
>> optimized in a way
>> that it expected to be called from certain places (but obviously not
>> from native code generated on the fly).
>>
>> That's really weird.
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list