hackclub / putting-the-you-in-cpu

A technical explainer by @kognise of how your computer runs programs, from start to finish.
https://cpu.land
MIT License
4.72k stars 146 forks source link

Why it is bad that the first page is mapped to zeroes? #10

Closed nalply closed 11 months ago

nalply commented 11 months ago

https://github.com/hackclub/putting-the-you-in-cpu/blob/93e595c4160653cff1e384dc22d0ab38cde2c52d/src/content/chapters/5-the-translator-in-your-computer.mdx#L37

Somewhat stupid question: why it is bad that the first page is mapped to zeroes?

It's funny to read but if not explained well it fosters a form of cargo cult, to be blunt, sorry!

kognise commented 11 months ago

Not a stupid question at all!

My experience with modern C is that null pointers are not supposed to be read. Dereferencing a null pointer alone is undefined behavior, "and a conforming implementation is allowed to assume that any pointer that is dereferenced is not null."

So it's a little funny for old systems to be the exact opposite.