4 ms·
> Hmm, I’m not familiar with cdqe. A quick search reveals that it sign-extends the lower 4 bytes into the full 8 bytes. Ah ha! A flash of insight illuminates my
by sterlind 3y ago
> Hmm, I’m not familiar with cdqe. A quick search reveals that it sign-extends the lower 4 bytes into the full 8 bytes. Ah ha! A flash of insight illuminates my grasping waddles. Could it be that kmalloc() is implicitly defined at the call site, so the compiler assumes the return type is a 32-bit int, chucking out the top half of the pointer value?
This really shows the glory, and the horror, of low-level systems programming. You make a seemingly-simple change, which surfaces a bug, which leads to gruesome crashes - the kind where the black box ends up in pieces - which you finally somehow trace back to an odd assembly instruction, which happened because you forgot to include a header so the C compiler simply hallucinated a function prototype! Because header files weren't free in the '70s, apparently!
It requires the kind of mind that can diagnose a leaky head gasket from a customer pantomiming goosh-goosh sounds.
- codyd51 3y agoHi, author here! Haha, yes, you’ve summed it up pretty well. I was unsure whether to write this post as, in one sense, it’s detective work in which I’m the investigator, and a slightly younger and more sloppy version of myself is the culprit. As you said, though, there's also more to it: the system takes on a life of its own, with different parts of the stack interacting in unexpected and complex ways, in an environment that doesn’t give me much help to write things correctly (and occasionally presents footguns on a silver platter). It’s really gratifying to see people reading and identifying with it, and I’m also extending my thanks to the user who posted this to HN!