Page 1 of 1
Was this a stupid mistake?
Posted: Wed Jun 06, 2007 12:20 am
by pcmattman
OK, I was coding my fopen function to fix some bugs, and all of a sudden my kfree tells me it's trying to free non-heap memory. I think to myself, 'why?'...
Here's why:
Code: Select all
char* fbuff = (char*) kmalloc( 256 );
fbuff = (char*) PadFilename( (uchar_t*) filename );
10 minutes I sat there until I thought of saving the first address...
Code: Select all
char* fbuff = (char*) kmalloc( 256 );
uint_t fbuff_addr = (uint_t) fbuff; /** we trash the fbuff pointer, and I don't yet know how **/
fbuff = (char*) PadFilename( (uchar_t*) filename );
And then I figured it out:
Code: Select all
char* fbuff = (char*) kmalloc( 256 );
uint_t fbuff_addr = (uint_t) fbuff; /** we trash the fbuff pointer, and I don't yet know how **/
fbuff = (char*) PadFilename( (uchar_t*) filename ); /** just figured it out... **/
I just overwrote the pointer in the next line of code
So, was this a stupid mistake?
Posted: Wed Jun 06, 2007 2:15 am
by Zacariaz
i have no clue what you talking about, but isnt any mistake kinda stupid?
Posted: Wed Jun 06, 2007 3:01 am
by distantvoices
Stuff of that sort always happens.
It's just mistakes, nothing bad.
Learn from this experience, young padawan, and don't hesitate to continue. You'll gonna make more mistakes. They'll grow in level, of course, and hide way better.
Stay safe
Posted: Wed Jun 06, 2007 3:03 am
by pcmattman
One bug I had once had each memory block allocated by my malloc running all over the place, so data was in the wrong place - corrupted memory.
Now that's all fixed
Posted: Wed Jun 06, 2007 3:07 am
by distantvoices
Reminds me of some hidden and really hard to find bug inside my paging stuff: I 've just allocated pages for pagetables and assigned them. Of course, they weren't zeroed out, so the mmu actually FOUND some memory to translate a given address the cpu has put on the address bus.
unfortunately, this caused the oddest of bugs to show up and none of them were reproduceable - initially. After a while of watching I 've been able to deduce a certain pattern, and from that I 've drawn the conlusion, that my memory management 's been buggy.
Well, and once that 's been clear, smashing the f***ing bug 's been a walk in the park.
The difficult stuff is discovering where the bloody heck the bug is hidden.
Posted: Wed Jun 06, 2007 9:28 am
by Aali
the best bugs come from not flushing the TLB properly, though
everything looks okay, every pagetable is correct, and you still trash memory pseudo-randomly
Posted: Fri Jun 08, 2007 7:51 am
by inflater
Everybody are making mistakes, humans,
computers and maybe animals too.
inflater
Posted: Sun Jun 17, 2007 2:59 pm
by Candy
Best thing you can do when making a mistake is to note what went wrong, how you figured that out and how you fixed it. I've been able to use a number of things from here - nonobvious non-normal things - in my work. The two most odd things that both my OS and my work had was one triple fault problem (spurious interrupt handler not installed, for both) and one executable-not-fully-loaded problem (which was pretty much undebuggable, in either case, except that I had a sharp lookout for nice numbers and a lot of guts saying "it's this". OS hit the limit at 32k, work item hit at 1M).
Posted: Mon Jun 18, 2007 1:50 am
by os64dev
inflater wrote:Everybody are making mistakes, humans,
computers and maybe animals too.
inflater
Computers don't make mistakes, only the people using them.
Posted: Mon Jun 18, 2007 1:53 am
by AJ
What about changes in bit patterns due to cosmic rays?
(I know, I know...happens all the time, doesn't it...)
Posted: Mon Jun 18, 2007 4:38 am
by Brendan
Hi,
AJ wrote:What about changes in bit patterns due to cosmic rays?
(I know, I know...happens all the time, doesn't it...)
That would be caused by inadaquate shielding (a mistake made by human designers)...
Cheers,
Brendan