[llvm-commits] [compiler-rt] r169335 - /compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
Alexander Potapenko
glider at google.com
Tue Dec 4 15:30:01 PST 2012
Author: glider
Date: Tue Dec 4 17:30:00 2012
New Revision: 169335
URL: http://llvm.org/viewvc/llvm-project?rev=169335&view=rev
Log:
Fix a use-after-unmap bug in /proc/self/maps caching. The cached buffer was occasionally deleted in the MemoryMappingLayout destructor.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=169335&r1=169334&r2=169335&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Dec 4 17:30:00 2012
@@ -236,7 +236,11 @@
}
MemoryMappingLayout::~MemoryMappingLayout() {
- UnmapOrDie(proc_self_maps_.data, proc_self_maps_.mmaped_size);
+ // Only unmap the buffer if it is different from the cached one. Otherwise
+ // it will be unmapped when the cache is refreshed.
+ if (proc_self_maps_.data != cached_proc_self_maps_.data) {
+ UnmapOrDie(proc_self_maps_.data, proc_self_maps_.mmaped_size);
+ }
}
void MemoryMappingLayout::Reset() {
More information about the llvm-commits
mailing list