Skip to content

Commit d4acc47

Browse files
committedJul 2, 2019
[GWP-ASan] [Scudo] Add GWP-ASan backtrace for alloc/free to Scudo.
Summary: Adds allocation and deallocation stack trace support to Scudo. The default provided backtrace library for GWP-ASan is supplied by the libc unwinder, and is suitable for production variants of Scudo. If Scudo in future has its own unwinder, it may choose to use its own over the generic unwinder instead. Reviewers: cryptoad Reviewed By: cryptoad Subscribers: kubamracek, mgorny, #sanitizers, llvm-commits, morehouse, vlad.tsyrklevich, eugenis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D64085 llvm-svn: 364966
1 parent f2055c5 commit d4acc47

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎compiler-rt/lib/scudo/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_MINIMAL_DYNAMIC_LIBS)
1212
append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_MINIMAL_DYNAMIC_LIBS)
1313
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_MINIMAL_DYNAMIC_LIBS)
1414
append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_MINIMAL_DYNAMIC_LIBS)
15+
append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer
16+
SCUDO_CFLAGS)
17+
append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG
18+
-mno-omit-leaf-frame-pointer SCUDO_CFLAGS)
1519

1620
set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
1721
# Use gc-sections by default to avoid unused code being pulled in.
@@ -35,7 +39,8 @@ if (COMPILER_RT_HAS_GWP_ASAN)
3539
# Currently, Scudo uses the GwpAsan flag parser. This backs onto the flag
3640
# parsing mechanism of sanitizer_common. Once Scudo has its own flag parsing,
3741
# and parses GwpAsan options, you can remove this dependency.
38-
list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser)
42+
list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser
43+
RTGwpAsanBacktraceLibc)
3944
list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS)
4045
endif()
4146

‎compiler-rt/lib/scudo/scudo_allocator.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#ifdef GWP_ASAN_HOOKS
2929
# include "gwp_asan/guarded_pool_allocator.h"
30+
# include "gwp_asan/optional/backtrace.h"
3031
# include "gwp_asan/optional/options_parser.h"
3132
#endif // GWP_ASAN_HOOKS
3233

@@ -671,7 +672,10 @@ void initScudo() {
671672
Instance.init();
672673
#ifdef GWP_ASAN_HOOKS
673674
gwp_asan::options::initOptions();
674-
GuardedAlloc.init(gwp_asan::options::getOptions());
675+
gwp_asan::options::Options &Opts = gwp_asan::options::getOptions();
676+
Opts.Backtrace = gwp_asan::options::getBacktraceFunction();
677+
Opts.PrintBacktrace = gwp_asan::options::getPrintBacktraceFunction();
678+
GuardedAlloc.init(Opts);
675679
#endif // GWP_ASAN_HOOKS
676680
}
677681

0 commit comments

Comments
 (0)
Please sign in to comment.