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

Prevent regions from being closed over and hidden from view #2203

Closed
nikomatsakis opened this issue Apr 14, 2012 · 13 comments
Closed

Prevent regions from being closed over and hidden from view #2203

nikomatsakis opened this issue Apr 14, 2012 · 13 comments
Assignees
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@nikomatsakis
Copy link
Contributor

Because a &T type is copyable, it is currently possible to close over them using an fn@() (and, eventually, iface@). This is clearly wrong. We need a new kind---perhaps heap or gc?---indicating data which is not only copyable but also copyable into a shared closure. This goes in between copy/send, I think.

@ghost ghost assigned nikomatsakis Apr 14, 2012
@graydon
Copy link
Contributor

graydon commented Apr 20, 2012

Shared or unique, same problem.

I don't think this is a kinding problem, I think it's a region problem. You should not be able to write a region pointer into any region other than one of its own subregions. Forming a heap closure is such a write, and should be prohibited just as forming a heap record full of stack region pointers would be.

@nikomatsakis
Copy link
Contributor Author

A heap record is totally allowed.

@nikomatsakis
Copy link
Contributor Author

To clarify, it is legal to do this:

let x = 3;
let f = @{g: &x};

that poses no particular problem. I could see it being useful if you have a long-running computation with some context that is passed by region ptr, but the internal data used by the computation might be garbage-collected.

Naturally all of those heap-allocated records will not be accessible after the computation finishes.

@graydon
Copy link
Contributor

graydon commented Apr 20, 2012

Wow, I totally thought (and think) that should not be legal. We'll have to discuss once I'm at an irc window :)

@nikomatsakis
Copy link
Contributor Author

this is done for closures in commit 0e42004

@pnkfelix
Copy link
Member

related to #5723

@Aatch
Copy link
Contributor

Aatch commented Aug 13, 2013

I think that has been fixed by the work @bblum did on trait and closure bounds.

Closing, re-open if I'm wrong.

@Aatch Aatch closed this as completed Aug 13, 2013
@bblum
Copy link
Contributor

bblum commented Aug 13, 2013

I didn't solve region-related issues; we still lack the capability to write ~Trait:'a or somesuch. @nikomatsakis can confirm.

@bblum bblum reopened this Aug 13, 2013
@catamorphism
Copy link
Contributor

Marked as clarifying - @nikomatsakis will investigate.

@pcwalton
Copy link
Contributor

Nominating because I believe this is fixed.

@pnkfelix
Copy link
Member

@nikomatsakis still needs to investigate, he is not certain it is fixed, and if it isn't, it still is on plate for 1.0

@aturon
Copy link
Member

aturon commented Sep 18, 2014

Nominating. I believe this issue has been resolved with #16453

@pnkfelix
Copy link
Member

closing as fixed

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
deprecate -Zmiri-allow-uninit-numbers and -Zmiri-allow-ptr-int-transmute

Cc rust-lang/miri#2187 rust-lang/miri#2188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

8 participants