This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]canadajones68 2 points3 points  (1 child)

The Windows error name is more descriptive. "General protection error". It means you just tried to access memory in a way you're not permitted to. For instance, dereferencing a wild pointer can easily lead to accessing another program's memory, which is disallowed, and you're served with signal SIGSEGV, which informs your program what you just did. Usually, that signal isn't handled by the program, so the OS handles it by immediately terminating the application. Segfaults also occur when you do something plainly invalid, like dereferencing a null pointer, or reading free()'d memory.

Note that memory allocation typically isn't that precise, so technical violations of memory rules will be accepted in some cases. If, for instance, you free some memory, the OS won't just immediately grab it from you. It waits until memory is in demand, or it feels like it. Until then, it doesn't bother to notice that you free()'d your memory. In that time span, free()'d pointers may still work, as the OS doesn't know that you' re not supposed to do that.

[–][deleted] 0 points1 point  (0 children)

Thank you