Skip to content

Commit dce1d64

Browse files
committed
Fix ASAN
1 parent ab54d7f commit dce1d64

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

thread/thread.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ namespace photon
199199
uint64_t rwlock_mark;
200200
void* retval;
201201
};
202-
char* buf;
202+
char* buf = nullptr;
203203
char* stackful_alloc_top;
204204
size_t stack_size;
205205
// offset 96B
@@ -295,7 +295,9 @@ namespace photon
295295

296296
#if defined(__has_feature)
297297
# if __has_feature(address_sanitizer) // for clang
298-
# define __SANITIZE_ADDRESS__ // GCC already sets this
298+
# ifndef __SANITIZE_ADDRESS__
299+
# define __SANITIZE_ADDRESS__ // GCC already sets this
300+
# endif
299301
# endif
300302
#endif
301303

@@ -904,7 +906,7 @@ R"(
904906
mov x28, x29
905907
mov x29, xzr
906908
)"
907-
#ifdef __ADDRESS_SANITIZER__
909+
#ifdef __SANITIZE_ADDRESS__
908910
R"(
909911
bl _asan_start //; asan_start()
910912
)"
@@ -993,9 +995,9 @@ R"(
993995
func = (uint64_t)&spinlock_unlock;
994996
arg = &lock;
995997
}
998+
auto ref = sw.to->stack.pointer_ref();
996999
ASAN_DIE_SWITCH(sw.to);
997-
_photon_switch_context_defer_die(
998-
arg, func, sw.to->stack.pointer_ref());
1000+
_photon_switch_context_defer_die(arg, func, ref);
9991001
__builtin_unreachable();
10001002
}
10011003

0 commit comments

Comments
 (0)