Table des matières
Notes segmentation fault
Pour comprendre et analyser l'origine d'un tel plantage dans vos programmes, vous pouvez compiler avec les options de débogage de GCC (gcc -g) et utiliser un outil comme GDB ou AddressSanitizer (Coddy Tech).
Common Causes
- Null or Uninitialized Pointers: Dereferencing a pointer that points to a random memory address instead of a valid allocation.
- Buffer Overflow / Out-of-Bounds Access: Writing or reading past the end of an array or buffer.
- Stack Overflow: Allocating too much memory on the stack (such as a massive local array) instead of the heap (using
std::vectorin C++ or dynamic allocation). - Use-After-Free: Accessing memory after it has already been freed or deleted.
How to Debug It
- Use GDB: Run your program inside the GNU Debugger (gdb ./your_program) and type run, then backtrace (or bt) once it crashes to find the exact line of code causing the fault.
- Check Memory with Valgrind: Run valgrind --leak-check=yes ./your_program to catch invalid reads, writes, and memory corruption.
- Inspect Array and Stack Sizes: If working in C/C++, replace raw fixed-size arrays with safe containers like std::vector. If you want to troubleshoot further, let me know:
- What programming language or tool are you running?
- Can you share the code snippet or stack trace around where the crash happens?
Segmentation Fault - segmentation violation - address not mapped - invalid memory access
Code 11 / 139
L'erreur “Exited with code -11” (ou Code de sortie -11 / exit code -11) signifie presque toujours que votre programme a été arrêté brutalement par le système d'exploitation à cause d'une erreur de segmentation (Segmentation Fault / SIGSEGV). En informatique, le code de sortie d'un processus crashé par un signal Unix correspond souvent à - (le numéro du signal). Le signal 11 étant SIGSEGV (Invalid memory reference).
You didn't find a definitive answer because there isn't one. It's up to the author of the program to decide what exit codes they wish to use. Standard C only says that exit(0) or exit(EXIT_SUCCESS) indicate that the program is successful, and that exit(EXIT_FAILURE) indicates an error of some kind. (Returning a value from main is equivalent to calling exit with that value.) Most common operating systems including Windows, Linux, OSX, etc. use 0 for success and values from 1 to 255 to indicate errors; still choosing between error codes is up to the application writer, the value 11 isn't anything special.
Under Linux and most other Unix variants, the signal number 11 indicates a segmentation fault,… A segmentation fault happens when a program makes some kind of invalid memory access, so it's a plausible consequence of accessing an array out of bounds, or an error in pointer arithmetic, or trying to access a null pointer, or other pointer-related errors. Signal 11 is not the same thing as exit code 11: when a program dies due to a signal, it's marked as having been killed by a signal, rather than having exited normally. Unix shells report signals by reporting an exit code which is the signal number plus 128, so 139 for a segmentation fault.
