Skip to content

Valgrind / FD Checks

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
Terminal window
valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes ./cub3D <map.cub>
Terminal window
valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes ./cub3D_bonus <map.cub>

For uninitialized-value diagnostics:

Terminal window
valgrind --track-origins=yes --leak-check=full --track-fds=yes ./cub3D <map.cub>

Target state:

in use at exit: 0 bytes in 0 blocks
All heap blocks were freed -- no leaks are possible

Target state:

ERROR SUMMARY: 0 errors from 0 contexts

Ideal target state after a clean graphical shutdown:

only 3 open (3 std) at exit

If the environment keeps extra descriptors inside X11/MLX internals, inspect the owning stack before treating it as a project leak.

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.

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=yes after a minimal app startup/exit scenario
  • make and make bonus pass
  • norminette include srcs srcs_bonus passes
  • 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.