Was this a stupid mistake?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply

Was this a stupid mistake?

Yes
16
84%
No
3
16%
 
Total votes: 19

pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Was this a stupid mistake?

Post 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 :D

So, was this a stupid mistake?
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

i have no clue what you talking about, but isnt any mistake kinda stupid?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Post 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
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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 :D
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Post 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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Aali
Member
Member
Posts: 58
Joined: Sat Apr 14, 2007 12:13 pm

Post 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
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Everybody are making mistakes, humans, computers and maybe animals too. ;)

inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post 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).
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

What about changes in bit patterns due to cosmic rays? :P (I know, I know...happens all the time, doesn't it...)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
AJ wrote:What about changes in bit patterns due to cosmic rays? :P (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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply