# Container exited with code 139 (segfault)

- **ID:** `docker/container-exited-139-segfault`
- **Domain:** docker
- **Category:** runtime_error
- **Error Code:** `139`
- **Verification:** ai_generated
- **Fix Rate:** 72%

## Root Cause

The application inside the container crashed due to a segmentation fault, often caused by memory access violations, stack overflow, or incompatible shared libraries.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 24.0.5 | active | — | — |
| Linux 5.10.0 | active | — | — |
| glibc 2.35 | active | — | — |

## Workarounds

1. **Enable core dumps inside the container: add '--ulimit core=-1' and mount a volume for core files: 'docker run --ulimit core=-1 -v /tmp/cores:/cores myapp'. Then analyze with gdb: 'gdb /path/to/binary /cores/core'.** (80% success)
   ```
   Enable core dumps inside the container: add '--ulimit core=-1' and mount a volume for core files: 'docker run --ulimit core=-1 -v /tmp/cores:/cores myapp'. Then analyze with gdb: 'gdb /path/to/binary /cores/core'.
   ```
2. **Check for incompatible shared libraries: run 'ldd /usr/bin/myapp' inside the container. If any library is 'not found', rebuild the image with correct library versions.** (75% success)
   ```
   Check for incompatible shared libraries: run 'ldd /usr/bin/myapp' inside the container. If any library is 'not found', rebuild the image with correct library versions.
   ```

## Dead Ends

- **Increase container memory limit with --memory** — Segfault is often not due to memory limit; increasing memory may mask the issue but not fix the root cause. (60% fail)
- **Rebuild the image with --no-cache** — Cache invalidation does not fix application logic errors or library incompatibilities. (70% fail)
- **Run container with --security-opt seccomp=unconfined** — Unconfined seccomp may allow more syscalls but does not prevent segfaults from application bugs. (55% fail)
