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

sync::Arc is failing to free memory #13210

Closed
ghost opened this issue Mar 30, 2014 · 2 comments
Closed

sync::Arc is failing to free memory #13210

ghost opened this issue Mar 30, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 30, 2014

Quick test to reproduce, check against d79fbba

extern crate sync;

use sync::Arc;

fn main()
{
    let _ = Arc::new(~"failed to drop");
}

valgrind results

colin@Colin-ubuntu:~/Source$ valgrind --leak-check=full ./failed_to_drop
Memcheck, a memory error detector
Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
Command: ./failed_to_drop


HEAP SUMMARY:
    in use at exit: 54 bytes in 2 blocks
  total heap usage: 16 allocs, 14 frees, 950 bytes allocated

54 (24 direct, 30 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 2
   at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x40507F: rt::global_heap::malloc_raw::h9abfb11fdd4fbd35cba::v0.0 (in /home/colin/Source/failed_to_drop)
   by 0x405007: rt::global_heap::exchange_malloc::h1a731dc6869c0c73Vaa::v0.0 (in /home/colin/Source/failed_to_drop)
   by 0x404E99: arc::Arc$LT$T$GT$::new::haa6209d493a9d577raa::v0.0 (in /home/colin/Source/failed_to_drop)
   by 0x404DE4: main::hed1e648887e7476fgaa::v0.0 (in /home/colin/Source/failed_to_drop)
   by 0x438642: start::closure.7865 (in /home/colin/Source/failed_to_drop)
   by 0x4D3452: rt::task::Task::run::closure.41627 (in /home/colin/Source/failed_to_drop)
   by 0x4DE5AB: rust_try (in /home/colin/Source/failed_to_drop)
   by 0x4D32B1: rt::task::Task::run::h19b1ba3b1fab6483os9::v0.10.pre (in /home/colin/Source/failed_to_drop)
   by 0x438433: start::h7087cc56d053c8b1zvd::v0.10.pre (in /home/colin/Source/failed_to_drop)
   by 0x438223: lang_start::hcbb6c5fc89f3553bTud::v0.10.pre (in /home/colin/Source/failed_to_drop)
   by 0x404E4E: main (in /home/colin/Source/failed_to_drop)

LEAK SUMMARY:
   definitely lost: 24 bytes in 1 blocks
   indirectly lost: 30 bytes in 1 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 0 bytes in 0 blocks
        suppressed: 0 bytes in 0 blocks

For counts of detected and suppressed errors, rerun with: -v
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
@ghost ghost changed the title ARC is failing to free memory sync::Arc is failing to free memory Mar 30, 2014
@ghost
Copy link
Author

ghost commented Mar 30, 2014

Looking through arc.rs it looks like the bug with how the reference counting was used in drop. fetch_sub returns the old value, not the new one. Meaning you need to check for 1 and not 0.

@alexcrichton
Copy link
Member

@brson, this is a strong indication to me that valgrind is not running on the snapshot bots, even though we believe it to be running.

bors added a commit that referenced this issue Mar 30, 2014
This is a fix for #13210. fetch_sub returns the old value of the atomic variable, not the new one.
@bors bors closed this as completed in 9fc45c1 Mar 31, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 8, 2024
…ednet

lintcheck: force warn all lints

It occurred to me that like `--filter` we could use `--force-warn` for normal operations, we especially want to see lints that crates decided were too annoying or were false positives

Also excludes `clippy::cargo` from the default set as nobody is really writing those and it slows things down

r? `@xFrednet`

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

1 participant