Page 2 of 2
Re:Does malloc work?
Posted: Wed Nov 02, 2005 1:52 am
by Candy
You could make a few practical test cases that test a simulated normal use. If they work, there's a very high likelyness that you won't have a big bug.
Then you go to pathological test cases, which is the final limit of test cases. Try to allocate the max size, N times 1/N of the max, bytes, stuff like that. Things you wouldn't normally do but that should be the limit of the possibilities.
When they all work, I would claim that you've tested enough. By the way, make a regression test program that's included in a "make test" that tests these things over again. That allows you to do "make test" and to instantly hear what's wrong.
Re:Does malloc work?
Posted: Wed Nov 02, 2005 7:20 am
by OZ
You will definetely have to come up with your own 'testing ideas' no way around it - but back to the point, that your code crashes after you allocated 31 blocks.
That is almost 2 mb - I dont know your memory setup, especially where you start your heap.
Perhaps you're facing a similiar situation like I did. Meaning if your code works 31 times and then crashes doesn't seem to be in the alloc code (well it could be - you should know best) , but maybe in your page code underneath.
Are you sure that this code works properly?
Perhaps you reserved 2 mb for your heap and no additional paging is needed but after this mem got used the first try to get a new free page crashes.
You already got exception handling, right? So it's definetely no page fault?
Re:Does malloc work?
Posted: Wed Nov 02, 2005 8:29 am
by distantvoices
debugging 101: KNow where your eip is at any time. Make drafts. Place printfs to trace the code. Lads - it isn't as if a malloc lib is the greatest miracle around, eh? it's one of the few straight forward things in os dev land.
(ok ok, I've had my own troubles too .. got them sorted out with looots of printfs and looots of getch() to get a step by step thing.)
BTW: Malloc shouldn't cause the OS to crash: it should cause it to clear out the failing process and continue with what is still able to work - the rest of it - and complain about low memory. That's all. No Crash. Ever. Well -I admint: My OS has a bug in exactly this area. It removes the faulting process - but starting another one causes the thing to crap out with halali oh damn.
STay safe
Re:Does malloc work?
Posted: Wed Nov 02, 2005 9:50 am
by Zioo
Okay... I'll se if i can get some time to make a lot of debugging and testing, over the next days (maybe weeks)..
But thanks to everybody for give me information and help... I'll maybe return if anything goes totally wrong.. =)