[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Corruption of high TPA
I'm pretty sure that kind of problem can occur also after Mshrink(), I
will make additional tests tonight.
I was right :S
The good thing is that the MMU does its job.
Standard programs use Mshrink() at startup in order to reduce the TPA to the
optimal size, and put the stack pointer at the new top of the TPA.
If the new TPA top occurs to be on a 8K boundary after Mshrink(), and if an
OS call is made just after, the program crashes when memory protection is
enabled. Because the MMU marked the memory just after as unreadable, as it
does not belong to the process anymore. I verified that by falling
intentionally into this specific case.
However, we must not be afraid. The probability of bad luck is 1/2048. The
programs linked with the MiNTLib are not affected, because between Mshrink()
and main(), 100 bytes are already pushed on the new stack.
So the rule is :
Every time you set the stack to a new location, be sure there are some
readable bytes just after. 64 bytes should be enough.
I'm going to provide a tiny patch for the MiNTLib about that.
--
Vincent Rivière