[pulse] model C variadic out-parameters to fix false MEMORY_LEAK_C - #2078
Open
SuryanshSS1011 wants to merge 1 commit into
Open
[pulse] model C variadic out-parameters to fix false MEMORY_LEAK_C#2078SuryanshSS1011 wants to merge 1 commit into
SuryanshSS1011 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partially addresses #1937 (the
MEMORY_LEAK_Cfalse positive; the companionPULSE_UNINITIALIZED_VALUEfalse positives are left for follow-up, see Known limitations).Problem
Pulse falsely reports
MEMORY_LEAK_Cwhen memory is allocated and stored through a variadic out-parameter, as inva_arg(a, char**); *p = malloc(...). Theva_argresult is disconnected from the caller's argument, andtrim_actuals_if_var_argdrops the variadic actuals at the interprocedural boundary, so there is nothing to reconnect the write to. A plain non-variadicchar**out-parameter is handled correctly, so this is specific tova_arg.Fix
This rides the existing specialization mechanism. A new
variadic_actualsfield onSpecialization.Pulse.tcarries the caller's extra actuals,PulseSpecialization.applyseeds them into a global bridge array during specialized re-analysis, and theva_argmodel reads successive elements from it. The read is type-gated to pointer results so value-returning variadics such as a summingsum(int n, ...)are unaffected. Regression tests are added and the C pulse suite is otherwise unchanged.Known limitations
The companion
PULSE_UNINITIALIZED_VALUEfalse positives on the same out-parameters are not addressed here, since those need true caller-actual binding that the specialization's callee-formal-relative heap paths cannot carry, so the affected tests are marked with anFP_prefix.