Skip to content

ASAN on arm64 windows builds but crashes because SANITIZER_WINDOWS64 is used to do x86_64 instruction parsing #64319

Closed
@farzonl

Description

@farzonl

For context you can build asan for arm64 however it asserts in GetInstructionSize because it can't parse the arm instructions.

asan_build

SANITIZER_WINDOWS64 as defined should only be used to determine if we are working on a 32bit or 64bit operating system.

#if defined(_WIN64)
# define SANITIZER_WINDOWS64 1
#else
# define SANITIZER_WINDOWS64 0
#endif

However, in practice it is being used to parse x86_64 instructions.

static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
#if SANITIZER_WINDOWS64
if (memcmp((u8*)address, kPrologueWithShortJump1,
sizeof(kPrologueWithShortJump1)) == 0 ||
memcmp((u8*)address, kPrologueWithShortJump2,
sizeof(kPrologueWithShortJump2)) == 0) {
return 0;
}
#endif
switch (*(u64*)address) {
case 0x90909090909006EB: // stub: jmp over 6 x nop.
return 8;
}
switch (*(u8*)address) {
case 0x90: // 90 : nop
return 1;
case 0x50: // push eax / rax
case 0x51: // push ecx / rcx
case 0x52: // push edx / rdx
case 0x53: // push ebx / rbx
case 0x54: // push esp / rsp
case 0x55: // push ebp / rbp
case 0x56: // push esi / rsi
case 0x57: // push edi / rdi
case 0x5D: // pop ebp / rbp

I put up a patch: here https://reviews.llvm.org/D156839
based on:
farzonl@223ee30

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions