Files
falco/userspace
Adnan Ali 6d20070f27 fix(metrics): Prevent race condition crash during metrics collection on shutdown
This fixes a segmentation fault that occurs when /metrics endpoint is accessed during Falco shutdown. The crash happens as the webserver continues serving /metrics requests after outputs and inspectors have been destroyed.

Changes:

- Create cleanup_outputs action to handle outputs destruction
- Create print_stats action for stats printing
- Reorder teardown steps to stop webserver before destorying outputs
- Move outputs.reset() from process_events to cleanup_outputs()

This eliminates the race condition by ensuring the webserver stops accepting requests before any subsystems are destroyed. The synchronisation behaviour of output.reset() block till queue flushed is preserved.

Signed-off-by: Adnan Ali <adduali1310@hotmail.com>
2026-03-16 10:46:29 +01:00
..