vendredi 27 février 2015

Protect memory from a potentially seg faulting function call


How can one safely call a function that might segfault without corrupting the stack or the heap?


These SO questions cover using signal handlers and setjmp.h to regain control.


Coming back to life after Segmentation Violation


Best practices for recovering from a segmentation fault


They neglect the likely memory corruption that occurs prior to a seg fault.


What strategies can be used to isolate the memory space of a function and its caller?


This is just a curiosity question, there's no specific problem I'm trying to solve. Let's just suppose we're programming something that absolutely cannot crash -- pacemaker, Mars orbiter, nuclear launch control, take your pick. We've already thoroughly unit tested all our code and formally proven its correctness. For bureaucratic reasons we have to use C++ and Linux.


I was trying to sketch this out with clone(). My idea was to run the function with as much isolation as possible and pass data back and forth by squirreling it away at the bottom of the child's stack.


Is that reasonable or is there a better way to do this?





Aucun commentaire:

Enregistrer un commentaire