Practical debugging exercises for C/C++ developers working on Linux systems.
This repository contains intentionally broken programs used to practice debugging with real Linux tools such as GDB, Valgrind, sanitizers, strace, systemd and journalctl.
It is designed for technical training, junior developer coaching and practical debugging methodology.
- Segmentation faults
- Invalid memory access
- Use-after-free
- Double free
- Memory leaks
- Race conditions
- Deadlocks
- Core dumps
- GDB
- Valgrind
- AddressSanitizer
- ThreadSanitizer
- strace
- systemd service failures
- journalctl-based investigation
Many developers can write code, but struggle when a program crashes, freezes, leaks memory or behaves inconsistently.
These labs teach a structured debugging approach:
- Reproduce the issue
- Observe the symptoms
- Collect evidence
- Form hypotheses
- Use the right tool
- Validate the root cause
- Document the fix
The goal is not only to fix bugs, but to learn how to reason from symptoms to evidence.
Recommended environment:
- Linux
- GCC or Clang
- Make
- GDB
- Valgrind
- strace
- systemd
- journalctl
Optional but recommended:
- AddressSanitizer
- ThreadSanitizer
- CMake
| Lab | Topic | Main tool |
|---|---|---|
| 01 | Segmentation fault | GDB |
| 02 | Memory leak | Valgrind |
| 03 | Use-after-free | AddressSanitizer |
| Lab | Topic | Main tool |
|---|---|---|
| 04 | Deadlock | GDB |
| 05 | Missing file / syscall error | strace |
| 06 | Crashing Linux service | systemd + journalctl |
For each lab:
- Build the broken program
- Run it and observe the failure
- Reproduce the issue reliably
- Investigate with the suggested tool
- Identify the root cause
- Fix the bug
- Write a short debugging note
Example debugging note:
Symptom:
Tool used:
Evidence found:
Root cause:
Fix:
Lesson learned:cpp-linux-debugging-labs/
├── labs/
│ ├── 01-segfault-gdb/
│ ├── 02-memory-leak-valgrind/
│ └── 03-use-after-free-asan/
├── LICENSE
└── README.mdAdditional labs and documentation are planned and will be added progressively.
This repository supports:
- C/C++ training
- Linux debugging training
- junior developer coaching
- technical rescue preparation
- embedded Linux reliability fundamentals
It demonstrates a practical debugging approach based on reproduction, evidence collection, tool-assisted investigation and clear technical documentation.
This project is released under the MIT License.
The code and exercises are provided for educational purposes and may be reused, modified and adapted with attribution.