top | item 42561112

(no title)

jacinda | 1 year ago

Related (and hilarious): https://scholar.harvard.edu/files/mickens/files/thenightwatc...

> What is despair? I have known it—hear my song. Despair is when you’re debugging a kernel driver and you look at a memory dump and you see that a pointer has a value of 7. THERE IS NO HARDWARE ARCHITECTURE THAT IS ALIGNED ON 7. Furthermore, 7 IS TOO SMALL AND ONLY EVIL CODE WOULD TRY TO ACCESS SMALL NUMBER MEMORY. Misaligned, small-number memory accesses have stolen decades from my life.

All James Mickens' USENIX articles are fun (for a very specific subset of computer scientist - the kind that would comment on this thread). https://mickens.seas.harvard.edu/wisdom-james-mickens

discuss

order

hinkley|1 year ago

I don’t know if it’s still a thing but there used to be debugging tools that would put a page of memory marked as either read only or unreadable in front of every malloc call so that any pointer arithmetic with a math error would trigger a page fault which could be debugged. It worked in apps that didn’t use too much of total memory or too many fine grained allocations. I mean obviously turning every 8 byte pointer into a whole memory page could consume all of memory very quickly. But in front of arrays or large data structures that could work.

saagarjha|1 year ago

In this case the write bypassed page protections

lupire|1 year ago

I don't understand. Pointers aren't numbers, and can only be compared when inside a common array. What is small number memory?

:-)

MobiusHorizons|1 year ago

I realize you are probably referring to UB in c/c++, but of course in hardware memory addresses are numbers. And when debugging, it’s really the hardware version of events that matters, since the compiler has already done whatever optimizations it wants.

ryao|1 year ago

Pointers are numbers representing memory addresses. This is very obvious if you look at the definition of NULL in C. It is:

  #define NULL ((void *)0)
As of C99, C also has uintptr_t, which lets you treat pointers as integers.