3 ms·
> Another implementation feat of T's was that it allowed interrupts between any two instructions of user code. That was the goal, but the T3 compiler actually
by lisper 8y ago
> Another implementation feat of T's was that it allowed interrupts between any two instructions of user code.
That was the goal, but the T3 compiler actually turned out to have a very subtle bug that manifested itself as the single hardest bug I have ever dealt with in my career. We used T to write research code for rovers and robotic arms at JPL. This code ran on two different machines: Sun3's running Solaris, and brandless embedded systems running vxWorks, but both running the same T compiler targeting the 68020 processor.
On the embedded systems we would get random crashes, but the same code running on Solaris ran flawlessly. Post-mortems revealed massive and random heap corruption, so the crash was manifesting itself long after the root cause. Because the problem was random an could not be reliably reproduced, it was impossible to find the root cause. And that is how matters stood for nearly a year until someone (I don't remember who, but it wasn't me) finally figured out how to reproduce the problem reliably. Then I spent a couple of days single-stepping through machine code until I finally found the problem: the stack pointer was being decremented while a live value was still on the stack. That value was accessed by the very next instruction. Those two instructions were simply out of order.
On Solaris this didn't matter because all the code ran in user space and was single-threaded. But vxWorks does not have a protected kernel address space. When an interrupt happens, that interrupt is processed on whatever process stack is currently active. So if you got an interrupt exactly between the stack pointer decrement and the subsequence load, the value was corrupted, and a few thousand instructions later everything would go kablooey.