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

Task that outlives root task leaks memory #126

Closed
jyasskin opened this issue Jul 25, 2010 · 4 comments
Closed

Task that outlives root task leaks memory #126

jyasskin opened this issue Jul 25, 2010 · 4 comments

Comments

@jyasskin
Copy link
Contributor

$ cat ~/tmp/test2.rs 
fn child2(str s) {
}

fn main() {
  spawn child2("hi");
}
$ ./rustboot -L . ~/tmp/test2.rs -o ~/tmp/test2 && ~/tmp/test2
rt: fatal, 'leaked memory in rust main loop (1 objects)' failed, rt/rust.cpp:32

Passing an int instead of a str (as spawn.rs does) doesn't leak, and having the main thread yield several times (as spawn-fn.rs does) allows the child to exit, which also avoids the leak.

@mbebenita
Copy link
Contributor

This is because the task fails to unwind correctly if it's never executed. Here child2() never gets a chance to start before it is killed by main(). At this point the task's stack is in an inconsistent state which confuses the unwind glue. The frame pointer should be in the right place, and the frame_glue_fns should be initialized.

The unwind glue fails to drop the reference to the string, thus causing a leak.

@jyasskin
Copy link
Contributor Author

My memory of the case I reduced this from indicates that "outliving" also causes leaks, not just "never starting". But that could be obsolete. I'll try to produce a test case along those lines after "never started" is fixed.

@mbebenita
Copy link
Contributor

I'll try to add support for putting tasks to sleep, should make these types of bugs easier to explore.

@graydon
Copy link
Contributor

graydon commented Jan 27, 2011

WONTFIX (not required for bootstrapping, also likely to change semantics when tasking is implemented in rustc)

oli-obk pushed a commit to oli-obk/rust that referenced this issue Jul 19, 2017
kazcw pushed a commit to kazcw/rust that referenced this issue Oct 23, 2018
* avx: _mm256_zextps128_ps256

* avx: _mm256_zextpd128_pd256

* avx: _mm256_set_m128

* avx: _mm256_set_m128d

* avx: _mm256_castpd_ps

* avx: _mm256_castps_pd

* avx: _mm256_castps_si256

* avx: _mm256_castsi256_ps

* avx: _mm256_zextsi128_si256

* avx: _mm256_set_m128i
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
eddyb pushed a commit to eddyb/rust that referenced this issue Jun 30, 2020
celinval pushed a commit to celinval/rust-dev that referenced this issue Dec 6, 2024
rust-lang#126)

### Description

This PR includes contracts and proof harnesses for the four APIs as_ptr,
cast, as_mut_ptr, and as_non_null_ptr which are part of the NonNull
library in Rust.

### Changes Overview:

Covered APIs:
NonNull::as_ptr: Acquires the underlying *mut pointer
NonNull::cast: Casts to a pointer of another type
NonNull:: as_mut_ptr:  Returns raw pointer to array's buffer
NonNull::as_non_null_ptr:  Returns a non-null pointer to slice's buffer

Proof harness:
non_null_check_as_ptr
non_null_check_cast
non_null_check_as_mut_ptr
non_null_check_as_non_null_ptr

Revalidation

To revalidate the verification results, run kani verify-std -Z
unstable-options "path/to/library" -Z function-contracts -Z
mem-predicates --harness ptr::non_null::verify. This will run all four
harnesses in the module. All default checks should pass:

```
SUMMARY:
 ** 0 of 128 failed

VERIFICATION:- SUCCESSFUL
Verification Time: 0.8232234s

Complete - 4 successfully verified harnesses, 0 failures, 4 total.

```
Towards issue rust-lang#53  

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Zyad Hassan <[email protected]>
Co-authored-by: Zyad Hassan <[email protected]>
Co-authored-by: Michael Tautschnig <[email protected]>
Co-authored-by: Qinyuan Wu <[email protected]>
This issue was closed.
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

3 participants