Fix memory leak in mono/mini/aot-compiler.c - #126308
Conversation
8a51be5 to
12ec34b
Compare
2806695 to
89064be
Compare
89064be to
0185e4a
Compare
|
@lewing I know it's a minor change, but is this applicable to wasm? If yes, we can take it. |
|
Workflow state for the Holistic Review Orchestrator. {
"version": 5,
"last_dispatched_commit": "0185e4a0b73b138b074c8029e68a95695c8cb1fb",
"last_dispatched_base_ref": "main",
"last_dispatched_base_sha": "3ade0b55c797a31f6800040e3ae3c5c75bc0d2dc",
"last_reviewed_commit": "0185e4a0b73b138b074c8029e68a95695c8cb1fb",
"last_reviewed_base_ref": "main",
"last_reviewed_base_sha": "3ade0b55c797a31f6800040e3ae3c5c75bc0d2dc",
"last_recorded_worker_run_id": "29680700591",
"review_attempt_commit": "",
"review_attempt_base_ref": "",
"review_attempt_count": 0,
"max_review_attempts": 5,
"review_history_format": "holistic-review-disclosure-v1",
"review_history": [
{
"commit": "0185e4a0b73b138b074c8029e68a95695c8cb1fb",
"review_id": 4730521821
}
]
} |
There was a problem hiding this comment.
Holistic Review
Motivation: The GString *export_symbols allocated at the top of add_managed_to_native_wrappers (line 5403) was only freed on the branch where acfg->aot_opts.export_symbols_outfile is set (via g_string_free(..., FALSE) to extract the buffer). When that option is unset, the GString and its backing buffer leaked on every invocation. The change adds the missing else branch to free it. This is a genuine, well-scoped leak fix; the impact is small (the PR notes ~16 bytes when the option is empty) but the correction is sound.
Approach: A two-line else clause calls g_string_free(export_symbols, TRUE) to release both the GString and its character buffer when no output file is configured. This mirrors the existing consuming branch and correctly passes TRUE (free the segment) since the buffer is not otherwise extracted. The logic is complete: both branches of the if now dispose of export_symbols, with no double-free or use-after-free risk. No behavioral change beyond reclaiming memory.
Summary: LGTM. The fix is correct, minimal, and addresses a real leak. The only observation is a cosmetic style deviation from the Mono convention of a space before ( (g_string_free( vs g_string_free (), noted inline; it does not affect correctness. No functional, safety, or test concerns.
Detailed Findings
No actionable correctness issues. One inline style nit on the added line regarding the space-before-parenthesis convention used elsewhere in this file.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 44.4 AIC · ⌖ 10.4 AIC · ⊞ 10K
0185e4a to
6ac4a76
Compare
Free GString export_symbols that allocates in add_native_to_managed_wrappers with a minimum size of 16 bytes. Signed-off-by: Aleksandr Dovydenkov <asd@altlinux.org> Found by Linux Verification Center (linuxtesting.org) with SVACE.
6ac4a76 to
f8d463b
Compare
The
GString export_symbolsis removed in only one execution branch. Freeing does not occur unless theicfg->aot_opts.export_symbols_outfilefield is set, which is set in only one place:aot-compiler.cfunctionmono_aot_parse_options: opts->export_symbols_outfile = g_strdup (arg + strlen ("export-symbols-outfile="));.The error only occurs during compilation with an empty
export-symbols-outfile=option. The maximum loss is 16 bytes per compilation.Signed-off-by: Aleksandr Dovydenkov asd@altlinux.org
Found by Linux Verification Center (linuxtesting.org) with SVACE.