Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeviceAsan] Enlarge nullpointer redzone to better detect problem #2243

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/loader/layers/sanitizer/asan_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ void ReportGenericError(const DeviceSanitizerReport &Report,
// Try to demangle the kernel name
KernelName = DemangleName(KernelName);

getContext()->logger.always("\n====ERROR: DeviceSanitizer: {} on {}",
getContext()->logger.always("\n====ERROR: DeviceSanitizer: {} on {} ({})",
ToString(Report.ErrorType),
ToString(Report.MemoryType));
ToString(Report.MemoryType),
(void *)Report.Address);
getContext()->logger.always(
"{} of size {} at kernel <{}> LID({}, {}, {}) GID({}, "
"{}, {})",
Expand Down
10 changes: 8 additions & 2 deletions source/loader/layers/sanitizer/asan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "ur_sanitizer_layer.hpp"
#include "ur_sanitizer_utils.hpp"

// The bigger the redzone size, the better we can detect this error.
// But if the redzone is too big, then it can cause false positives.
#define NULLPTR_REDZONE_SIZE (4096)

namespace ur_sanitizer_layer {

std::shared_ptr<ShadowMemory> GetShadowMemory(ur_context_handle_t Context,
Expand Down Expand Up @@ -50,7 +54,8 @@ ur_result_t ShadowMemoryCPU::Setup() {
ShadowEnd = ShadowBegin + ShadowSize;

// Set shadow memory for null pointer
auto URes = EnqueuePoisonShadow({}, 0, 1, kNullPointerRedzoneMagic);
auto URes = EnqueuePoisonShadow({}, 0, NULLPTR_REDZONE_SIZE,
kNullPointerRedzoneMagic);
if (URes != UR_RESULT_SUCCESS) {
getContext()->logger.error("EnqueuePoisonShadow(NullPointerRZ): {}",
URes);
Expand Down Expand Up @@ -113,7 +118,8 @@ ur_result_t ShadowMemoryGPU::Setup() {
// Set shadow memory for null pointer
ManagedQueue Queue(Context, Device);

Result = EnqueuePoisonShadow(Queue, 0, 1, kNullPointerRedzoneMagic);
Result = EnqueuePoisonShadow(Queue, 0, NULLPTR_REDZONE_SIZE,
kNullPointerRedzoneMagic);
if (Result != UR_RESULT_SUCCESS) {
getContext()->logger.error("EnqueuePoisonShadow(NullPointerRZ): {}",
Result);
Expand Down
Loading