You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use REAL(malloc) in function Allocate of struct Allocator
like this
const int rate = 7;
int r = rand() % 10;
if(r <= rate){
uptr needed_size = size + kChunkHeaderSize;
void *allocated = REAL(malloc)(needed_size);
return allocated;
}
question : but failed !
error info :
==20489==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000 (pc 0x00000000 bp 0xbe96796c sp 0xbe967518 T0)
==20489==Hint: pc points to the zero page.
==20489==The signal is caused by a READ memory access.
==20489==Hint: address points to the zero page.
#0 0x0 () #1 0xf9344 in ReportDeadlySignalImpl /root/opt/asan_random/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:222:9 #2 0xf9344 in __sanitizer::ReportDeadlySignal(__sanitizer::SignalContext const&, unsigned int, void ()(__sanitizer::SignalContext const&, void const, __sanitizer::BufferedStackTrace*), void const*) /root/opt/asan_random/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:236:27 #3 0xc9f18 in __asan::ErrorDescription::Print() /root/opt/asan_random/lib/asan/asan_errors.h:440:7 #4 0xc9f18 in __asan::ScopedInErrorReport::~ScopedInErrorReport() /root/opt/asan_random/lib/asan/asan_report.cpp:141:55 #5 0xc9f18 in __asan::ReportDeadlySignal(__sanitizer::SignalContext const&) /root/opt/asan_random/lib/asan/asan_report.cpp:211:47 #6 0xc8050 in __asan::AsanOnDeadlySignal(int, void*, void*) /root/opt/asan_random/lib/asan/asan_posix.cpp:37:21 #7 0xb6c8912c /build/glibc-FUvrFr/glibc-2.28/signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:77
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ()
==20489==ABORTING
Can you give me a method to avoid this question ? thank you!!!
The text was updated successfully, but these errors were encountered:
Generally, if you want to be able to call a real function, you should add a line to InitializeAsanInterceptors in compiler-rt/lib/asan/asan_interceptors.cpp, like
ASAN_INTERCEPT_FUNC(malloc);
but you will also need to match those calls with READL(free), which could be tricky.
If you do this, you will have to figure out how to call the system free() on the pointer obtained from the system malloc.
You can't pass such a pointer to asan's deallocation routines.
Various other things may break too.
DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, uptr) DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
explicit Allocator(LinkerInitialized)
: quarantine(LINKER_INITIALIZED),
fallback_quarantine_cache(LINKER_INITIALIZED) {
if(INTERCEPT_FUNCTION(free)){
char buf[] = "free intercept true\n";
write(STDERR_FILENO, buf, sizeof(buf));
}
else{
char buf[] = "free intercept false\n";
write(STDERR_FILENO, buf, sizeof(buf));
}
if(!INTERCEPT_FUNCTION(malloc)){
char buf[] = "malloc intercept true\n";
write(STDERR_FILENO, buf, sizeof(buf));
}
else{
char buf[] = "malloc intercept true\n";
write(STDERR_FILENO, buf, sizeof(buf));
}
}
like this
const int rate = 7;
int r = rand() % 10;
if(r <= rate){
uptr needed_size = size + kChunkHeaderSize;
void *allocated = REAL(malloc)(needed_size);
return allocated;
}
question : but failed !
error info :
==20489==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000 (pc 0x00000000 bp 0xbe96796c sp 0xbe967518 T0)
==20489==Hint: pc points to the zero page.
==20489==The signal is caused by a READ memory access.
==20489==Hint: address points to the zero page.
#0 0x0 ()
#1 0xf9344 in ReportDeadlySignalImpl /root/opt/asan_random/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:222:9
#2 0xf9344 in __sanitizer::ReportDeadlySignal(__sanitizer::SignalContext const&, unsigned int, void ()(__sanitizer::SignalContext const&, void const, __sanitizer::BufferedStackTrace*), void const*) /root/opt/asan_random/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:236:27
#3 0xc9f18 in __asan::ErrorDescription::Print() /root/opt/asan_random/lib/asan/asan_errors.h:440:7
#4 0xc9f18 in __asan::ScopedInErrorReport::~ScopedInErrorReport() /root/opt/asan_random/lib/asan/asan_report.cpp:141:55
#5 0xc9f18 in __asan::ReportDeadlySignal(__sanitizer::SignalContext const&) /root/opt/asan_random/lib/asan/asan_report.cpp:211:47
#6 0xc8050 in __asan::AsanOnDeadlySignal(int, void*, void*) /root/opt/asan_random/lib/asan/asan_posix.cpp:37:21
#7 0xb6c8912c /build/glibc-FUvrFr/glibc-2.28/signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:77
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ()
==20489==ABORTING
Can you give me a method to avoid this question ? thank you!!!
The text was updated successfully, but these errors were encountered: