Your how-the-heck-did-it-worked moments?
Posted: Wed May 11, 2011 3:36 am
Have you ever found a bug so evil that you wondered how the heck did it all worked at all?
I guess you had, so tell the story?
To start, i was recently debugging the filesystem handling code, looking for the weird tiny problem that popped up in a multithreaded write test. The file content was swapped between threads every now and then.
Eventually i got down to the thread handling, where i found that thread-private areas of all threads were reallocated on each thread creation! Thus, all of the thread private variables could get randomized.
Fixing that collapsed everything.
Luck of the memory manager until now? Not quite. Turned out that call gates were not thread safe, and the reply could have been returned to any thread that might have called the same module at the same time. Thus, threads merged and swapped their data every now and then, somehow cancelling two problems most of the time at cost of rare random crashes.
And an entire damn OS was working fine on top of that!
I guess you had, so tell the story?
To start, i was recently debugging the filesystem handling code, looking for the weird tiny problem that popped up in a multithreaded write test. The file content was swapped between threads every now and then.
Eventually i got down to the thread handling, where i found that thread-private areas of all threads were reallocated on each thread creation! Thus, all of the thread private variables could get randomized.
Fixing that collapsed everything.
Luck of the memory manager until now? Not quite. Turned out that call gates were not thread safe, and the reply could have been returned to any thread that might have called the same module at the same time. Thus, threads merged and swapped their data every now and then, somehow cancelling two problems most of the time at cost of rare random crashes.
And an entire damn OS was working fine on top of that!