Skip to content

Introduce the memory neutrality property - #752

Merged
Heizmann merged 10 commits into
devfrom
mh/memory_neutrality
Oct 9, 2025
Merged

Introduce the memory neutrality property#752
Heizmann merged 10 commits into
devfrom
mh/memory_neutrality

Conversation

@Heizmann

@Heizmann Heizmann commented Oct 4, 2025

Copy link
Copy Markdown
Member

We call a function memory neutral if all memory that was dynamically allocated is freed before the function returns.

This commit addresses the following problems:

  • The term allocation purity that we used in the past is a misnomer. Allocation purity means that a function does not allocate memory dynamically.
  • We have a setting that checks whether the main function is memory neutral and a setting that checks whether some function is memory neutral. These settings interfere with each other. (What if the check for all functions is set but the check for main is not set?)
  • Users usually do not want to check whether all functions are memory neutral, but users might want to know whether some specific function is memory neutral.

Solution:
Replace both settings with one new setting in which users specify a list of functions for which memory neutrality is checked.

@Heizmann
Heizmann force-pushed the mh/memory_neutrality branch 2 times, most recently from d8c5b44 to 00a6a7b Compare October 6, 2025 02:34

@schuessf schuessf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for improving our settings!
I have left a few (mostly minor) comments.

Heizmann added a commit that referenced this pull request Oct 7, 2025
Heizmann added a commit that referenced this pull request Oct 7, 2025
Heizmann added a commit that referenced this pull request Oct 7, 2025
Heizmann added a commit that referenced this pull request Oct 7, 2025
@schuessf

schuessf commented Oct 7, 2025

Copy link
Copy Markdown
Member

Looks good now, I will approve if the nightly succeeds.

We call a function *memory neutral* if all memory that was dynamically allocated is freed before the function returns.

This commit addresses the following problems:
* The term allocation purity that we used in the past is a misnomer. Allocation purity means that a function does not allocate memory dynamically.
* We have a setting that checks whether the main function is memory neutral and a setting that checks whether some function is memory neutral. These settings interfere with each other. (What if the check for all functions is set but the check for main is not set?)
* Users usually do not want to check whether all functions are memory neutral, but users might want to know whether some specific function is memory neutral.

Solution:
Replace both settings with one new setting in which users specify a list of functions for which memory neutrality is checked.
Applied the following commands.
find . -name "*.epf" -type f -exec sed -i 's#cacsl2boogietranslator/Check\\ for\\ the\\ main\\ procedure\\ if\\ all\\ allocated\\ memory\\ was\\ freed=true#cacsl2boogietranslator/Check\\ memory\\ neutrality=main#g' {} \;
find . -name "*.epf" -type f -exec sed -i 's#cacsl2boogietranslator/Check\\ for\\ the\\ main\\ procedure\\ if\\ all\\ allocated\\ memory\\ was\\ freed=false#cacsl2boogietranslator/Check\\ memory\\ neutrality=#g' {} \;
Update all epfs that contain allocation purity manually
@Heizmann
Heizmann force-pushed the mh/memory_neutrality branch from 290ed92 to 07392df Compare October 9, 2025 00:09
@Heizmann
Heizmann merged commit 0e6531c into dev Oct 9, 2025
1 check was pending
Heizmann added a commit that referenced this pull request Oct 9, 2025
Heizmann added a commit that referenced this pull request Oct 9, 2025
Heizmann added a commit that referenced this pull request Oct 9, 2025
@Heizmann
Heizmann deleted the mh/memory_neutrality branch October 9, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants