-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Failed asserting on Select drop #12042
Comments
My previous thoughts about destructors are not providing the soundness that I thought I was getting. I would expect code like this to not compile: struct Foo {
a: int
}
struct Bar<'a> {
a: &'a Foo,
}
impl Drop for Foo {
fn drop(&mut self) {
println!("dropping foo");
}
}
#[unsafe_destructor]
impl<'a> Drop for Bar<'a> {
fn drop(&mut self) {
println!("dropping bar {}", self.a.a);
}
}
fn main() {
let mut a = ~[];
let b = Foo { a: 2 };
a.push(Bar { a: &b });
} The output is
Which is clearly a use-after-free. I presume that this is why I had to write let mut handles = ~[];
let select = Select::new(); to let select = Select::new();
let mut handles = ~[]; your code should work alright. cc @nikomatsakis, just want to make sure that this isn't an unknown bug in destructors right now. Also, could any of the new marker types help me with this bug? |
Nominating. |
This is why you had to write unsafe destructor. This is not an unknown bug -- you should never write unsafe destructor on a type that "escapes" to the wild. It is only valid if you control exactly where that type is instantiated. #8861 would possibly help here. |
Not a 1.0 blocker, P-low. #8861 subsumes the high priority dtor semanitcs issue implicit here. |
If this is superseded by #8861, can it be closed? It seems like this is mostly a mistake and not really a bug. |
man this is some old code in this example I need to forward port here! |
Okay, here is my attempt to forward port the original code: http://is.gd/kk3Fb9 It now produces an error that And if you do the suggested rewrite from #12042 (comment) illustrated here: http://is.gd/aSNKtF then it compiles (and times out in the playpen)! Score one for #8861! It only took us a year to get there! So, i am closing. |
…-from-lang-config, r=jonas-schievink fix: remove angle brackets from language configuration This should fix rust-lang/rust-analyzer#12034 It looks like we shouldn't add any characters here that can be ambiguous, because it can make the editor highlight unrelated characters. This needs a parser to be correct, so the language server is the right place, not the editor. Upstream LSP feature request: microsoft/language-server-protocol#672 (but it might be possible to implement this as an extension today, as long as that doesn't conflict with the built-in highlighting).
…int-listing, r=Manishearth fix: metadata-collector lists wrong affected lints fixes rust-lang#12042 This PR addresses the issue where the `metadata collector` incorrectly generates the `Affected Lints` section when a comma is included in the configuration documentation. I made adjustments; however, if the `/// Lint: SOMETHING` section ends with `.` it always produces the correct output. For example, ```rust /// Lint: PUB_UNDERSCORE_FIELDS ``` should be ```rust /// Lint: PUB_UNDERSCORE_FIELDS. ``` changelog: none
This is reproduce able 100% with the following code. Looking at the disassembly the problem is that one of the handles drop function is called after the select drop is called.
output
The text was updated successfully, but these errors were encountered: