GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Fix memory leaks in linemap filename handling.

Fixes memory leaks by ensuring filenames associated with the linemap are properly managed and freed.

This commit addresses memory leaks in gccrs related to filename lifetimes within the linemap. Filenames are now leaked to live as long as the linemap itself, preventing them from being prematurely deallocated. This change involves removing include_extra_file usage, copying and leaking the filename parameter in the lexer, and removing related members from Session.

In Details

The gccrs lexer was leaking filenames by not freeing them after use. This commit corrects that by ensuring filenames are copied and leaked, so they live as long as the Linemap structure. This prevents memory exhaustion in long-running compilations or scenarios that heavily utilize the Linemap and its associated file tracking. Changes include modifying Lexer::Lexer to copy and leak, and removing unused Session members related to extra files.

For Context
Linemap
A data structure used in compilers to map source code locations (file, line, column) to internal representations, crucial for error reporting and debugging.
Lexer
The component of a compiler that reads the source code character by character and groups them into tokens.
Filed Under: gccrsmemory leaklexer