Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passManager should always call releaseMemory to avoid use-after-free bugs #4770

Closed
edwintorok opened this issue Jun 16, 2009 · 5 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla

Comments

@edwintorok
Copy link
Contributor

Bugzilla Link 4398
Resolution FIXED
Resolved on Mar 02, 2010 11:32
Version unspecified
OS Linux
Attachments passmanager patch, testcase
CC @sunfishcode

Extended Description

Currently some passes call releaseMemory (or their equivalent) in their run function, some don't (for example ScalarEvolution).

According to the documentation "This method is called after the run* method for the class, before the next call of run* in your pass."

However the PassManager doesn't do this for on-the-fly passes, which can cause use-after-free bugs if you are using ScalarEvolution from a ModulePass
(LoopInfo is rerun, but ScalarEvolution still has stale data from the previous LoopInfo run).

As discusses on llvm-commits the following should happen:

  • PassManager should call releaseMemory for on-the-fly passes too
  • PassManager should assert if it forgot to call releaseMemory
  • passes that have a releaseMemory equivalent should have the method renamed to releaseMemory
  • passes should no longer call releaseMemory in their run function
@edwintorok
Copy link
Contributor Author

assigned to @edwintorok

@llvmbot
Copy link
Member

llvmbot commented Jun 29, 2009

Watch out for extra white spaces in the patch. Do you really need wasRun? Isn't Changed enough ? Otherwise the patch looks good.

@edwintorok
Copy link
Contributor Author

Watch out for extra white spaces in the patch.

I'll clean them up.

Do you really need wasRun? Isn't
Changed enough ?

wasRun is needed to make sure that releaseMemory isn't called before the first
call to run(), and that it is called after the first call to run().

Changed isn't always set to true after a run(), and yet the pass could have allocated memory.

Otherwise the patch looks good.

Thanks, I'll apply the patch.

@sunfishcode
Copy link
Member

The patch is applied, right? Is this bug fixed?

@edwintorok
Copy link
Contributor Author

The patch is applied, right? Is this bug fixed?

I should've closed the bug after applying the patch, thanks for reminding.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants