Page 1 of 1

[Solved] Strange bug once kernel size grows

Posted: Mon Nov 19, 2018 8:55 pm
by SnowWalkerJ
I am struggling with a strange problem.

Problem:

One day I found my kernel triggers General Protection in the middle of "strftime". If I just delete some unnecessary code, the problem disappears. However, once I add more meaningless and harmless code, it re-appears. It doesn't matter where I add my code. It's like once the size of kernel excess such amount, the problem triggers.

Sometimes it's General Protection; sometimes it's ok but string literals doesn't initialize correctly.

I know this isn't much information. But I am new to this circumstance and I don't know what information to give.


Anyone has any idea what this might be about? Or What I can do to locate the real problem?


Thanks in advance!

Re: Strange bug once kernel size grows

Posted: Mon Nov 19, 2018 9:35 pm
by neon
Hi,

Are you using a custom boot loader? How are you loading the kernel?

There was a similar issue reported long ago on one of our projects which was due to the boot loaders' ReadSector function not being written to support multi-segment reads. After the kernel size exceeded the segment (64k) it would corrupt itself during loading.

Re: Strange bug once kernel size grows

Posted: Mon Nov 19, 2018 10:33 pm
by SnowWalkerJ
neon wrote:Hi,

Are you using a custom boot loader? How are you loading the kernel?

There was a similar issue reported long ago on one of our projects which was due to the boot loaders' ReadSector function not being written to support multi-segment reads. After the kernel size exceeded the segment (64k) it would corrupt itself during loading.
Thank you! You saved me!

It turns out that the 'number of sectors' param was set too small when loading the kernel.

You just pointed it out!