diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-04-03 17:06:45 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-04-03 17:08:33 -0700 |
| commit | f4b293f0e379291d2c2e9c56713862d5546a9e3a (patch) | |
| tree | 1670904813760765f98a4c1020a2f2ea3b09e0c0 /src/rt/rust_uv.cpp | |
| parent | 1f892dcb01c93c3af4be3c291f22da88e38bd835 (diff) | |
| download | rust-f4b293f0e379291d2c2e9c56713862d5546a9e3a.tar.gz rust-f4b293f0e379291d2c2e9c56713862d5546a9e3a.zip | |
rt: Fix the 0 bytes lost issue
This is a workaround for #1815. libev uses realloc(0) to free the loop, which valgrind doesn't like. We have suppressions to make valgrind ignore them. Valgrind also has a sanity check when collecting allocation backtraces that the stack pointer must be at least 512 bytes into the stack (at least 512 bytes of frames must have come before). When this is not the case it doesn't collect the backtrace. Unfortunately, with our spaghetti stacks that valgrind check triggers sometimes and we don't get the backtrace for the realloc(0), it fails to be suppressed, and it gets reported as 0 bytes lost from a malloc with no backtrace. This fixes the issue by alloca'ing 512 bytes before calling uv_loop_delete
Diffstat (limited to 'src/rt/rust_uv.cpp')
| -rw-r--r-- | src/rt/rust_uv.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 7e7486fca62..e3c29ae974a 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -83,6 +83,22 @@ rust_uv_loop_new() { extern "C" void rust_uv_loop_delete(uv_loop_t* loop) { + // FIXME: This is a workaround for #1815. libev uses realloc(0) to + // free the loop, which valgrind doesn't like. We have suppressions + // to make valgrind ignore them. + // + // Valgrind also has a sanity check when collecting allocation backtraces + // that the stack pointer must be at least 512 bytes into the stack (at + // least 512 bytes of frames must have come before). When this is not + // the case it doesn't collect the backtrace. + // + // Unfortunately, with our spaghetti stacks that valgrind check triggers + // sometimes and we don't get the backtrace for the realloc(0), it + // fails to be suppressed, and it gets reported as 0 bytes lost + // from a malloc with no backtrace. + // + // This pads our stack with some extra space before deleting the loop + alloca(512); uv_loop_delete(loop); } |
