Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Failure in a destructor leaks the entire task #16437

Closed
sfackler opened this issue Aug 12, 2014 · 1 comment
Closed

Failure in a destructor leaks the entire task #16437

sfackler opened this issue Aug 12, 2014 · 1 comment

Comments

@sfackler
Copy link
Member

I was under the impression that failure in a a destructor will leak that object, but not the entire task.

"dropped" doesn't print here:

struct Dropper {
    v: Vec<u8>,
}

impl Drop for Dropper {
    fn drop(&mut self) {
        println!("dropping");
    }
}

struct Failer;

impl Drop for Failer {
    fn drop(&mut self) {
        fail!();
    }
}

fn main() {
    let _d = Dropper { v: Vec::with_capacity(10000) };
    Failer;
}
==6462== Memcheck, a memory error detector
==6462== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==6462== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==6462== Command: ./test
==6462== 
task '<main>' failed at 'explicit failure', test.rs:15
==6462== 
==6462== HEAP SUMMARY:
==6462==     in use at exit: 12,288 bytes in 1 blocks
==6462==   total heap usage: 14 allocs, 13 frees, 13,000 bytes allocated
==6462== 
==6462== LEAK SUMMARY:
==6462==    definitely lost: 12,288 bytes in 1 blocks
==6462==    indirectly lost: 0 bytes in 0 blocks
==6462==      possibly lost: 0 bytes in 0 blocks
==6462==    still reachable: 0 bytes in 0 blocks
==6462==         suppressed: 0 bytes in 0 blocks
==6462== Rerun with --leak-check=full to see details of leaked memory
==6462== 
==6462== For counts of detected and suppressed errors, rerun with: -v
==6462== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)
@sfackler
Copy link
Member Author

Dup of #14875

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant