This document lists real bug scenarios in this repository as hands-on exercises.
- Reproduce the issue first.
- Write a failing test (or script) that proves the bug.
- Fix with the smallest safe change.
- Re-run
go test ./...andgo build ./....
- Category: Runtime panic / edge case
- Area: Monitoring
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/monitor.go(ContainerMonitor.GetMetrics) - Symptom: Program can panic with
slice bounds out of rangewhen container ID length is less than 8. - Repro hint: Run monitoring code against a short container ID (for example
"abc"). - What to debug: String slicing assumptions.
- Done when: Monitoring no longer panics for short IDs and returns metrics safely.
- Category: File I/O correctness
- Area: Layer metadata persistence
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(saveLayerMetadata) - Symptom:
defer file.Close()is scheduled before confirmingos.Create(...)succeeded. - Repro hint: Force create failure (permissions/path issue) and observe behavior.
- What to debug: Ordering of error handling and cleanup.
- Done when: File handles are only closed when file creation succeeds.
- Category: State inconsistency / observability bug
- Area: Container lifecycle
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(runWithoutNamespaces) - Symptom: Stored PID reflects the CLI process instead of the spawned container command process.
- Repro hint: Run a container and compare metadata PID with actual child process PID.
- What to debug: Process lifecycle timing (
cmd.Start/cmd.Run) and which PID should be recorded. - Done when: Metadata PID maps to the actual container command process.
- Category: Feature integration bug
- Area: CLI status and exec path
- Location:
- Reader:
/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(getContainerStatus,execCommand) - Writer path gap:
/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(runWithoutNamespaces)
- Reader:
- Symptom: Status/exec behavior can be incorrect because PID file expectations are not met.
- Repro hint: Run a container, inspect files under
/tmp/basic-docker/containers/<id>/, then tryps/exec. - What to debug: Contract mismatch between producer and consumer of runtime state.
- Done when: PID file lifecycle is consistent and dependent commands behave correctly.
- Category: Resource leak / scalability bug
- Area: Image pulling
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/image.go(Pull) - Symptom: Layer readers are closed with
deferinside loop, so descriptors stay open until function returns. - Repro hint: Pull image with many layers and watch file descriptor count/pressure.
- What to debug: Resource lifetime in loops.
- Done when: Each layer reader is closed promptly after extraction.
- Category: Configuration consistency bug
- Area: Image management
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/image.go(ListImages,Pull,LoadImageFromTar)/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(listImages)
- Symptom: Multiple code paths hardcode
/tmp/basic-docker/imagesinstead of consistently using shared directory variables. - Repro hint: Change runtime base directory and observe path inconsistencies.
- What to debug: Single source of truth for storage paths.
- Done when: Image paths are consistently derived from shared config.
- Category: Security bug
- Area: Image extraction
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/image.go(extractLayer,LoadImageFromTar) - Symptom: Tar extraction trusts archive entries and may write outside intended rootfs depending on archive content/tool behavior.
- Repro hint: Create a crafted tar with traversal-like paths and evaluate extraction safety.
- What to debug: Archive extraction safety boundaries.
- Done when: Extraction guarantees writes stay within target rootfs.
- Category: Reliability / silent failure
- Area: Container state persistence
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/main.go(runWithoutNamespaces) - Symptom: Calls to
UpdateContainerState(...)are not checked for errors. - Repro hint: Make state file path unwritable and run container lifecycle.
- What to debug: Error propagation in critical state updates.
- Done when: Failures to persist state are surfaced and handled predictably.
- Category: Concurrency and maintainability risk
- Area: Network management
- Location:
/home/runner/work/basic-docker-engine/basic-docker-engine/network.go - Symptom: Global
networksslice is read/written without synchronization. - Repro hint: Simulate concurrent network operations (or parallel tests) and look for races.
- What to debug: Shared state ownership and synchronization strategy.
- Done when: Concurrent operations are safe and deterministic.
- Reproduce and capture exact failure output.
- Add a failing test that isolates one bug.
- Fix one bug at a time (avoid broad refactors).
- Re-run:
go test ./...go build ./...
- Add a short note in your commit message: root cause + prevention idea.