diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-09-23 11:42:20 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-09-23 11:42:20 -0700 |
| commit | 61afef29a186513570bcbe4f6dfa635e31d8a610 (patch) | |
| tree | 7fc02dfa6a72410392a04717098186455c72eb9f /src/rt/rust_upcall.cpp | |
| parent | dbdeff659fb30fd845490cf215b5733e1e064d46 (diff) | |
| download | rust-61afef29a186513570bcbe4f6dfa635e31d8a610.tar.gz rust-61afef29a186513570bcbe4f6dfa635e31d8a610.zip | |
rt: Add a RUST_TRACK_ORIGINS debug flag to help track down memory corruption
Diffstat (limited to 'src/rt/rust_upcall.cpp')
| -rw-r--r-- | src/rt/rust_upcall.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 758d5622b10..7a96a5ef7cb 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -67,10 +67,13 @@ upcall_malloc(rust_task *task, size_t nbytes, type_desc *td) { // TODO: Maybe use dladdr here to find a more useful name for the // type_desc. + // TODO: Implement RUST_TRACK_ORIGINS + void *p = task->malloc(nbytes, "tdesc", td); memset(p, '\0', nbytes); task->local_allocs[p] = td; + debug::maybe_track_origin(task, p); LOG(task, mem, "upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR ") = 0x%" PRIxPTR, @@ -91,6 +94,8 @@ upcall_free(rust_task *task, void* ptr, uintptr_t is_gc) { (uintptr_t)ptr, is_gc); task->local_allocs.erase(ptr); + debug::maybe_untrack_origin(task, ptr); + task->free(ptr, (bool) is_gc); } |
