Valgrind / FD Checks
Purpose
Section titled “Purpose”Valgrind checks are used to validate runtime memory safety and file descriptor hygiene:
- no heap leaks
- no invalid reads or writes
- no use-after-free on shutdown paths
- no leaked project-owned file descriptors
Recommended Commands
Section titled “Recommended Commands”Mandatory
Section titled “Mandatory”valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes ./cub3D <map.cub>valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes ./cub3D_bonus <map.cub>With origins
Section titled “With origins”For uninitialized-value diagnostics:
valgrind --track-origins=yes --leak-check=full --track-fds=yes ./cub3D <map.cub>What to Check in Output
Section titled “What to Check in Output”Leak summary
Section titled “Leak summary”Target state:
in use at exit: 0 bytes in 0 blocksAll heap blocks were freed -- no leaks are possibleError summary
Section titled “Error summary”Target state:
ERROR SUMMARY: 0 errors from 0 contextsFile descriptors
Section titled “File descriptors”Ideal target state after a clean graphical shutdown:
only 3 open (3 std) at exitIf the environment keeps extra descriptors inside X11/MLX internals, inspect the owning stack before treating it as a project leak.
Scenarios to Run
Section titled “Scenarios to Run”Run checks on:
- valid mandatory map
- valid bonus map
- invalid parser cases (bad extension, bad headers, invalid map)
- early-exit cases (wrong arguments)
- runtime close paths (
ESC, window close in graphical environment)
This ensures both startup-failure cleanup and normal shutdown cleanup are covered.
Interpreting MLX/X11 Noise
Section titled “Interpreting MLX/X11 Noise”On some Linux and MLX environments, Valgrind may report warnings originating inside X11 or libxcb internals.
Treat these carefully:
- if stack traces point only to external libraries and your heap summary is clean, they may be runtime-library artifacts
- prioritize project-owned allocations, resource release order, and reproducible errors in your own code paths
- if needed, reproduce with
--track-origins=yesafter a minimal app startup/exit scenario
Practical Checklist Before Defense
Section titled “Practical Checklist Before Defense”makeandmake bonuspassnorminette include srcs srcs_bonuspasses- Valgrind on mandatory valid map is clean
- Valgrind on bonus valid map is clean
- FD output shows no project-owned descriptors left open
- invalid-input rejection paths do not crash
- Full graphical runtime validation requires an active X11 session.
- In headless environments, parser-only and startup-path checks remain useful, but MLX runtime coverage is limited.