Page 5 of 7

Posted: Sat Jan 05, 2008 11:49 pm
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...

Posted: Mon Jan 07, 2008 1:08 am
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. :/

Posted: Tue Jan 29, 2008 5:48 am
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.

Posted: Wed Jan 30, 2008 4:41 am
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

Posted: Wed Jan 30, 2008 2:29 pm
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.

Posted: Sat Feb 02, 2008 10:11 am
by neon
*ahem*

Clicky

...It was a long night and I was tired when I posted that.

Posted: Sat Feb 02, 2008 4:15 pm
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

Posted: Sat Feb 02, 2008 8:43 pm
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).

Posted: Sun Feb 03, 2008 2:29 pm
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.

Posted: Sun Feb 03, 2008 3:12 pm
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

Posted: Mon Feb 04, 2008 5:40 pm
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);
}

Posted: Tue Feb 05, 2008 12:55 am
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."

Posted: Sun Mar 23, 2008 1:37 pm
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.

Posted: Sun Mar 23, 2008 2:18 pm
by nekros
doing a >> instead of a << I felt really stupid.

Posted: Sun Mar 23, 2008 3:33 pm
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