Skip to content
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
1 change: 1 addition & 0 deletions boost/context/detail/externc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void __sanitizer_finish_switch_fiber( void *, const void **, size_t *);
extern "C" {
void __msan_start_switch_fiber( const void *, size_t);
void __msan_finish_switch_fiber( const void **, size_t *);
void __msan_unpoison( const volatile void *, size_t);
}
#endif

Expand Down
17 changes: 17 additions & 0 deletions boost/context/fiber_ucontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ struct BOOST_CONTEXT_DECL fiber_activation_record {
#if defined(BOOST_USE_MSAN)
__msan_finish_switch_fiber( (const void **) & current()->from->stack_bottom,
& current()->from->stack_size);
// On AArch64, LLVM loses MSan shadow for struct-padding bytes in return values
// (llvm/llvm-project#54476). On heap-allocated fiber stacks the dirty shadow
// accumulates across context switches and propagates via stack-slot reuse.
// Unpoison the whole fiber stack to prevent these false positives.
#if defined(__aarch64__)
if ( ! current()->main_ctx) {
__msan_unpoison( current()->stack_bottom, current()->stack_size);
}
#endif
#endif
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
return exchange( current()->from, nullptr);
Expand Down Expand Up @@ -241,6 +250,11 @@ struct BOOST_CONTEXT_DECL fiber_activation_record {
#if defined(BOOST_USE_MSAN)
__msan_finish_switch_fiber( (const void **) & current()->from->stack_bottom,
& current()->from->stack_size);
#if defined(__aarch64__)
if ( ! current()->main_ctx) {
__msan_unpoison( current()->stack_bottom, current()->stack_size);
}
#endif
#endif
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
return exchange( current()->from, nullptr);
Expand Down Expand Up @@ -302,6 +316,9 @@ class fiber_capture_record : public fiber_activation_record {
#if defined(BOOST_USE_MSAN)
__msan_finish_switch_fiber( (const void **) & from->stack_bottom,
& from->stack_size);
#if defined(__aarch64__)
__msan_unpoison( stack_bottom, stack_size);
#endif
#endif
Ctx c{ from };
try {
Expand Down