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

Incorrect check for memory safety in presence of closures #6395

Closed
silene opened this issue May 10, 2013 · 1 comment
Closed

Incorrect check for memory safety in presence of closures #6395

silene opened this issue May 10, 2013 · 1 comment

Comments

@silene
Copy link

silene commented May 10, 2013

With rust 0.6, the following code produces a segfault. Indeed, at the time of println, *y is no longer a managed pointer to a string, but an arbitrary value crafted by the closure.

enum A { B(@str), C(int) }
fn main() -> () {
  let mut x = B(@"");
  let f = || { x = C(0); };
  match x {
    B(ref y) => { f(); println(*y) },
    C(*) => ()
  }
}
@nikomatsakis
Copy link
Contributor

Duplicate of #2202 (but a nice example, thanks).

flip1995 added a commit to flip1995/rust that referenced this issue Dec 6, 2020
switch Version/VersionReq usages to RustcVersion

add `rustc-semver` to dependencies
switch `Version/VersionReq` usages to `RustcVersion`
changelog: none
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 6, 2020
Rollup of 4 pull requests

Successful merges:

 - rust-lang#6308 (add `internal-lints` feature to enable clippys internal lints (off by default))
 - rust-lang#6395 (switch Version/VersionReq usages to RustcVersion )
 - rust-lang#6402 (Add Collapsible match lint)
 - rust-lang#6407 (CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

changelog: rollup
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

No branches or pull requests

2 participants