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

For loops leak resources #17216

Closed
pczarn opened this issue Sep 13, 2014 · 2 comments · Fixed by #17246
Closed

For loops leak resources #17216

pczarn opened this issue Sep 13, 2014 · 2 comments · Fixed by #17246

Comments

@pczarn
Copy link
Contributor

pczarn commented Sep 13, 2014

for (_, leaked) in Some(((), box 0u)).move_iter() {  }

// LEAK SUMMARY:
// definitely lost: 8 bytes in 1 blocks

cc @pcwalton

@huonw huonw added the I-wrong label Sep 13, 2014
@bkoropoff
Copy link
Contributor

Getting my feet wet in the rustc code a bit, pay no mind to my drive-by observations:

  • This was introduced in caa564b
  • Using a tuple is key to triggering the bug. Using a simple identifier as the for loop binding does not trigger it.
  • This seems to be due to the special case for simple identifiers in store_for_loop_binding. Commenting out this special case results in a leak in all cases.

@bkoropoff
Copy link
Contributor

The pop_custom_cleanup_scope on this line looks like it should be a pop_and_trans_custom_cleanup_scope. This fixes it for me. I'll submit a PR after running a full make check.

bkoropoff added a commit to bkoropoff/rust that referenced this issue Sep 14, 2014
The cleanup scope of for loop bindings should translated when
popped to ensure resources are not leaked.
bkoropoff added a commit to bkoropoff/rust that referenced this issue Sep 14, 2014
bors added a commit that referenced this issue Sep 17, 2014
Trans the cleanup scope of for loop bindings so we don't leak resources.  Regression test included.

Closes #17216
lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
fix: extract mod to file should respect path attribute

close rust-lang/rust-analyzer#17181
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 a pull request may close this issue.

3 participants