Bug 1957362 - Revert MOZ_CRASH() behavior in ASAN builds to use regular null-pointer accesses r=glandium
ASAN builds should crash the same way as regular builds when encountering a MOZ_CRASH() macro. Changing this to abort() raised a SIGILL signal instead, which caused the ASAN crash signatures to become different from regular ones in turn causing confusion in automation. Differential Revision: https://phabricator.services.mozilla.com/D243658
This commit is contained in:
@@ -241,47 +241,41 @@ MOZ_NoReturn(int aLine) {
|
|||||||
* MOZ_CrashSequence() executes a sequence that causes the process to crash by
|
* MOZ_CrashSequence() executes a sequence that causes the process to crash by
|
||||||
* writing the line number specified in the `aLine` parameter to the address
|
* writing the line number specified in the `aLine` parameter to the address
|
||||||
* provide by `aAddress`. The store is implemented as volatile assembly code to
|
* provide by `aAddress`. The store is implemented as volatile assembly code to
|
||||||
* ensure it's always included in the output and always executed. This does not
|
* ensure it's always included in the output and always executed.
|
||||||
* apply to ASAN builds where we use `__builtin_trap()` instead, as an illegal
|
|
||||||
* access would trip ASAN's checks.
|
|
||||||
*/
|
*/
|
||||||
# if !defined(MOZ_ASAN)
|
|
||||||
static inline void MOZ_CrashSequence(void* aAddress, intptr_t aLine) {
|
static inline void MOZ_CrashSequence(void* aAddress, intptr_t aLine) {
|
||||||
# if defined(__i386__) || defined(__x86_64__)
|
# if defined(__i386__) || defined(__x86_64__)
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"mov %1, (%0);\n" // Write the line number to the crashing address
|
"mov %1, (%0);\n" // Write the line number to the crashing address
|
||||||
: // no output registers
|
: // no output registers
|
||||||
: "r"(aAddress), "r"(aLine));
|
: "r"(aAddress), "r"(aLine));
|
||||||
# elif defined(__arm__) || defined(__aarch64__)
|
# elif defined(__arm__) || defined(__aarch64__)
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"str %1,[%0];\n" // Write the line number to the crashing address
|
"str %1,[%0];\n" // Write the line number to the crashing address
|
||||||
: // no output registers
|
: // no output registers
|
||||||
: "r"(aAddress), "r"(aLine));
|
: "r"(aAddress), "r"(aLine));
|
||||||
# elif defined(__riscv) && (__riscv_xlen == 64)
|
# elif defined(__riscv) && (__riscv_xlen == 64)
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"sd %1,0(%0);\n" // Write the line number to the crashing address
|
"sd %1,0(%0);\n" // Write the line number to the crashing address
|
||||||
: // no output registers
|
: // no output registers
|
||||||
: "r"(aAddress), "r"(aLine));
|
: "r"(aAddress), "r"(aLine));
|
||||||
# elif defined(__sparc__) && defined(__arch64__)
|
# elif defined(__sparc__) && defined(__arch64__)
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"stx %1,[%0];\n" // Write the line number to the crashing address
|
"stx %1,[%0];\n" // Write the line number to the crashing address
|
||||||
: // no output registers
|
: // no output registers
|
||||||
: "r"(aAddress), "r"(aLine));
|
: "r"(aAddress), "r"(aLine));
|
||||||
# elif defined(__loongarch64)
|
# elif defined(__loongarch64)
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"st.d %1,%0,0;\n" // Write the line number to the crashing address
|
"st.d %1,%0,0;\n" // Write the line number to the crashing address
|
||||||
: // no output registers
|
: // no output registers
|
||||||
: "r"(aAddress), "r"(aLine));
|
: "r"(aAddress), "r"(aLine));
|
||||||
# else
|
# else
|
||||||
# warning \
|
# warning \
|
||||||
"Unsupported architecture, replace the code below with assembly suitable to crash the process"
|
"Unsupported architecture, replace the code below with assembly suitable to crash the process"
|
||||||
asm volatile("" ::: "memory");
|
asm volatile("" ::: "memory");
|
||||||
*((volatile int*)aAddress) = aLine; /* NOLINT */
|
*((volatile int*)aAddress) = aLine; /* NOLINT */
|
||||||
# endif
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
# define MOZ_CrashSequence(x, y) __builtin_trap()
|
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MOZ_CRASH_WRITE_ADDR is the address to be used when performing a forced
|
* MOZ_CRASH_WRITE_ADDR is the address to be used when performing a forced
|
||||||
@@ -294,7 +288,7 @@ static inline void MOZ_CrashSequence(void* aAddress, intptr_t aLine) {
|
|||||||
* SEGV at 0x0.
|
* SEGV at 0x0.
|
||||||
*/
|
*/
|
||||||
# ifdef MOZ_UBSAN
|
# ifdef MOZ_UBSAN
|
||||||
# define MOZ_CRASH_WRITE_ADDR 0x1
|
# define MOZ_CRASH_WRITE_ADDR ((void*)0x1)
|
||||||
# else
|
# else
|
||||||
# define MOZ_CRASH_WRITE_ADDR NULL
|
# define MOZ_CRASH_WRITE_ADDR NULL
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
Reference in New Issue
Block a user