Dumbest mistake you have ever made

Programming, for all ages and all languages.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

my newest and maybe worst one is here http://www.osdev.org/phpBB2/viewtopic.p ... 259#114259

I spent at least 2 hours trying to figure out why things weren't adding up...
Shalted
Posts: 19
Joined: Wed Nov 07, 2007 12:09 am

Post by Shalted »

Accidentally setting the stack to the end of the BSS, and wondering why my initial variables were getting destroyed when in deep recursion. :/
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I probably made some worse mistakes in the past but IMHO this'll qualify:

Assuming that my latest video card supported non-power-of-2 textures (I have older ones that do) and then wondering why everything appeared horribly distorted...
Which cost me 5 hours trying to fix the 'rest' of the code until I realized the card did in fact *not* support it.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Post by Laksen »

I think this one might qualify..

I've been sitting for 10 hours trying to get calls to the pci bios working properly, but I keep getting a 81h result(FUNC_NOT_SUPPORTED). I've done almost anything I could think of to find out what goes wrong. I know that I have the PCI bios in my real computer and Bochs supports it too. So I keep on getting the result. I take one last look at the compiler output which is fine, and then I decide to recheck my constants. I take a quick look but discovers something I forgot I changed a long time ago and I punch myself in the head:

Code: Select all

const
 cFindPCIDevice = 2;

...

function FindPCIDevice(vendid, devid: cardinal): integer;
begin
...
   pcicall(pciEntry+FindPCIDevice,...); //< crap!!!
...
end;
But at the bright side: Now my PCI system works :D
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

Not sure it's the stupidest mistake I made, but I was trying to get GCC/Binutils to run on my OS, and was wondering why gas was choking on GCC's assembly output, and spent hours looking through the GCC code (yes, not my own code). Then suddenly it occurred to me to check my own code, and found that the write function was not incrementing the fd's offset after a successful write.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

*ahem*

Clicky

...It was a long night and I was tired when I posted that.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

very recently in C#:

Code: Select all

while(i < 100)
{
    try {
        ...
    }
    catch{
        ...
    }
    i++;
}
gave lockup when exception was generated. to a while to notice missing finally
Author of COBOS
User avatar
B.E
Member
Member
Posts: 275
Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:

Post by B.E »

In one of my applications, I use to check an RSS feed more information about an event (I used to get an email when the event occured, which would give me an ID to find in the RSS feed which would give me more information). The problem was the RSS feed would only show events that were of any importance(which the website states).

My script read the RSS feed to find the ID, and of coruse wouldn't find it on the cases where it didn't meet the condition.

Took me 5 weeks to work it out. Tried everything (I though it may be a cache problem). After that I just laughed (after kicking my self).
Image
Microsoft: "let everyone run after us. We'll just INNOV~1"
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

Combuster wrote:I probably made some worse mistakes in the past but IMHO this'll qualify:

Assuming that my latest video card supported non-power-of-2 textures (I have older ones that do) and then wondering why everything appeared horribly distorted...
Which cost me 5 hours trying to fix the 'rest' of the code until I realized the card did in fact *not* support it.
Did you consider glPixelStorei with the unpacking alignment? Or, of course, the equivalent DirectX call?

We had a problem that textures that weren't a multiple of 4 horizontally were distorted. Ended up being alignment going wrong.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Post by distantvoices »

Today I've found a bug so hilarious and worth a week of asskicking just for the sheer dumbness! Meh! I feel silly.

Look, in the tcp/ip stack, I assign a PCB to a socket, so they know about each other - the standard interface socket and the special protocol related stuff.

Yeah. In tcp, you've got passive open, innit?

I've made a fine listen state, and if a syn packet strolls along and hits my listening pcb, I have it pop off a sibling for the actual connection. But alas, what have I done?

I've copied over the local ip address stored in the listening pcb! AH GOSH! This can as well be 0x00 for any ipaddress or interface. Sweet.

Now comes where the stuff becomes weird: I use the addresses stored in the pcb to build a tcp segment. well, they aren't to change for the actual connection, innit?

Yo! there i go, build a tcp header with all those nifty addresses and sorta and LO! calculate an even correct checksum - on my part of the connection.

Linux tcp/ip tells me: He, you 're a complete and utter ****! what the ruddy hell do you want with that checksum?

Alright - two days and a half ere I got the right Idea - to check the addresses stored in the fake ip header used for checksum calculation - what if I 've borked that.

Yeah. I've borked exactly that. Oh ****. I called myself quite a nifty set of names and actually tried to kick my @$$. Should have whipped it instead, that kicking didn't even hurt.
*lol*

stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
jgraef
Member
Member
Posts: 47
Joined: Wed Jan 16, 2008 7:37 am
Location: Wonsheim, Germany

Post by jgraef »

Hi,

It's not long ago I recoded my memory managment. After that I got Page Faults all the time from an address near the kernel stack, so I thought something with my stack is not right. It took me a few weeks until I discovered that I forgot to set the present bits of my pages.

Actually I also did a mistake with my Pagefault handler. Do you see the difference ;)

Code: Select all

void pagefault_handler() {
  u32 cr2;
  asm("mov %%cr2,%0"::"a"(cr2));
  printf("Process %d wanted to access address 0x%h.\n",curpid,cr2);
}

Code: Select all

void pagefault_handler() {
  u32 cr2;
  asm("mov %%cr2,%0":"=a"(cr2));
  printf("Process %d wanted to access address 0x%h.\n",curpid,cr2);
}
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

This is a while ago (about 3 months but it was before Christmas so it seemed like a while ago). I was adding an octree to optimising my scene rendering in my 3D framework.

An octree is basically representing the entire scene/world as a 3D cube, and this cube is subdivided into 8 smaller cubes. Each of these cubes are subdivided into another 8 smaller cubes. The scene keeps subdividing until you have the smallest cube that can fit around an object.

Each of these cubes can be represented as a node in a tree, each branching off into the 8 children.

So here was my code for inserting an object into an octree node that will recursively go up and down the tree to find the appropriate node:

Code: Select all

// inserts an IObject into the octree and returns the current node
OctreeNode *OctreeNode::insertNode(IObject *object)
{
   for(int child = 0; child < 8; child++)
   {
      if(object fits into child == true)
      {
          // create child node if it doesn't exist

          return m_child[child]->insertNode(object);
      }
   }
   else if(object fits into this node == true)
   {
      m_objects.push_back(object); // add to list of objects in this node
      return this;
   }
   else // if object doesn't fit inside children and it doesn't fit inside me, test parent
   {
      // if parent doesn't exist create it
      return m_parent->insertNode(object);
   }
}
Anyway, I was representing my light sources and points on the screen (which Direct3D drew as a single pixel) by just a point (so it had a width/height/depth of 0).

But every time I tested my code I would run out of memory. I checked my content manager to make sure I was only loading textures/meshes once, I checked the size of my nodes to make sure they didn't take up too much room, I tried removing items from my scene.

Eventually I realised that objects with a width, height, and depth of 0 would always fit into a child node since it was infinitely small. So my nodes were stuck recursively subdividing!

I fixed this problem - lights now have a huge bounding box which takes up the entire area they affect, and for any other object infinitely small I added a case that says "if a child node does not exist and this object is infinitely small, just add it to me."
My OS is Perception.
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

Back in July i was just starting to develop my OS. I was working on IRQs, but whenever one fired i would get a GPF. After several hours of thinking i realized that there were two things (int number and err code) that i pushed onto the stack, but forgot to pop, so when the iret instruction was executed, the stack was messed up and the cs, ss, eip and eflags registers were popped with the wrong values.
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

doing a >> instead of a << I felt really stupid.
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

nekros wrote:doing a >> instead of a << I felt really stupid.

Hehe, last I did that was two days ago (well, I should have done >> and did <<), and it was even more stupid because I wasn't writing new code, but just refractoring some old code to see if I could get it run a bit faster by moving things around. Normally you'd use copypaste for that, but since I'd also be renaming variables a bit, I just rewrote that shift, and then wondered why my synth (it was some DSP code I was working with) wouldn't track notes properly anymore. :P
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
Post Reply