Skip to content

Commit d64353d

Browse files
committed
Fix ASAN access stack after vstack destructed
1 parent 05c0481 commit d64353d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

thread/thread.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace photon
192192
uint64_t rwlock_mark;
193193
void* retval;
194194
};
195-
char* buf;
195+
char* buf = nullptr;
196196
char* stackful_alloc_top;
197197
size_t stack_size;
198198
// offset 96B
@@ -292,7 +292,9 @@ namespace photon
292292

293293
#if defined(__has_feature)
294294
# if __has_feature(address_sanitizer) // for clang
295-
# define __SANITIZE_ADDRESS__ // GCC already sets this
295+
# ifndef __SANITIZE_ADDRESS__
296+
# define __SANITIZE_ADDRESS__ // GCC already sets this
297+
# endif
296298
# endif
297299
#endif
298300

@@ -954,9 +956,10 @@ R"(
954956
func = (uint64_t)&spinlock_unlock;
955957
arg = &lock;
956958
}
959+
auto ref = sw.to->stack.pointer_ref();
957960
ASAN_DIE_SWITCH(sw.to);
958-
_photon_switch_context_defer_die(
959-
arg, func, sw.to->stack.pointer_ref());
961+
_photon_switch_context_defer_die(arg, func, ref);
962+
__builtin_unreachable();
960963
}
961964
__attribute__((used)) static
962965
void _photon_thread_die(thread* th) {

0 commit comments

Comments
 (0)