There are many questions on Stack Overflow asking about how a system handles memory leaks and what happens on abnormal termination. Examples:
https://stackoverflow.com/questions/6727383/dynamically-allocated-memory-after-program-termination
https://stackoverflow.com/questions/2975831/is-leaked-memory-freed-up-when-the-program-exits
However, I could not find any posts asking the same about memory corruption. Is handling of memory leaks and memory corruption by the Linux kernel the same? When the process exits, are the corrupted segments of memory freed and reclaimed, and are they safe to use by other processes?
Also, what about processes using POSIX shared memory (/dev/shm)? From my understanding it seems that shared memory does not get reclaimed by the system unless it is deleted by shm_unlink. (http://man7.org/linux/man-pages/man7/shm_overview.7.html) Does this mean that if shared memory segment somehow gets corrupted then the user is basically screwed until they reboot the system? Or will kernel clear the shared memory by shm_unlink automatically on user logout (without rebooting) after all user processes get killed?
Thanks!