Dumbest mistake you have ever made
- Combuster
- 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:
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.
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.
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:
But at the bright side: Now my PCI system works
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;
-
- Member
- Posts: 391
- Joined: Wed Jul 25, 2007 8:45 am
- Libera.chat IRC: aejsmith
- Location: London, UK
- Contact:
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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
very recently in C#:
gave lockup when exception was generated. to a while to notice missing finally
Code: Select all
while(i < 100)
{
try {
...
}
catch{
...
}
i++;
}
Author of COBOS
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).
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).
Microsoft: "let everyone run after us. We'll just INNOV~1"
Did you consider glPixelStorei with the unpacking alignment? Or, of course, the equivalent DirectX call?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.
We had a problem that textures that weren't a multiple of 4 horizontally were distorted. Ended up being alignment going wrong.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
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
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
BlueillusionOS iso image
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
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);
}
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
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:
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."
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);
}
}
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.
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.
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
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
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.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.