Live data from Hacker News

Memory Safe Context Switching

fil-c.org

31–32 of 32 posts

Re: Memory Safe Context Switching

#31

This is an article I wish I could have read many months ago. > Hence, the most basic safety issue with setjmp is that if we call it and then return from the function that had called it, the context saved by setjmp is not valid to longjmp to. > longjmp is only safe if it's called at a time when the stack frame used by setjmp could not have possibly been overwritten, since that is the only way to guarantee that the reg…

> What ruins this for C is the existence of pointers. Stacks aren't freely relocatable since pointers into the stack could exist. I sometimes wonder what computing would be like if the 80286 hadn't sucked, if segmentation had won over flat address spaces, and if we'd been able to do relocation pain-free by changing a segment base register in one spot instead of rewriting linear pointers everywhere. We could have done…

mmap with MAP_FIXED has allowed you to do this for some time.

Re: Memory Safe Context Switching

#32

Earlier quoted context omitted.

> What ruins this for C is the existence of pointers. Stacks aren't freely relocatable since pointers into the stack could exist. I sometimes wonder what computing would be like if the 80286 hadn't sucked, if segmentation had won over flat address spaces, and if we'd been able to do relocation pain-free by changing a segment base register in one spot instead of rewriting linear pointers everywhere. We could have done…

mmap with MAP_FIXED has allowed you to do this for some time.

Not if you have an address space conflict, e.g. if you want to move a stack within a single process. Linear addresses are relative to a whole address space root.
Post reply on HN