[Solved] Strange bug once kernel size grows

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SnowWalkerJ
Posts: 2
Joined: Mon Nov 19, 2018 8:47 pm

[Solved] Strange bug once kernel size grows

Post 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!
Last edited by SnowWalkerJ on Mon Nov 19, 2018 10:39 pm, edited 1 time in total.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Strange bug once kernel size grows

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
SnowWalkerJ
Posts: 2
Joined: Mon Nov 19, 2018 8:47 pm

Re: Strange bug once kernel size grows

Post 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!
Post Reply