Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests):
- FG#39: Missing s4u::Comm::wait_any_for example
+ - FG#42: Add support for ThreadSanitizer (TSan)
- FG!19: Removing RngStream
- FG!20: A module for RNG calls
- FG!21: Choice between ad-hoc and standard distributions implementations
#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
#include <sanitizer/asan_interface.h>
#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+#include <sanitizer/tsan_interface.h>
+#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
#endif
#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
this->asan_stack_ = get_stack_bottom();
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ this->tsan_fiber_ = __tsan_create_fiber(0);
+#endif
+ } else {
+ // not has_code(): in maestro context
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ this->tsan_fiber_ = __tsan_get_current_fiber();
#endif
}
}
if (stack_ == nullptr) // maestro has no extra stack
return;
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ __tsan_destroy_fiber(tsan_fiber_);
+#endif
#if HAVE_VALGRIND_H
if (RUNNING_ON_VALGRIND)
VALGRIND_STACK_DEREGISTER(valgrind_stack_id_);
to->asan_ctx_ = this;
__sanitizer_start_switch_fiber(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ __tsan_switch_to_fiber(to->tsan_fiber_, 0);
+#endif
swap_into_for_real(to);
SwappedContext* asan_ctx_ = nullptr;
bool asan_stop_ = false;
#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ void* tsan_fiber_;
+#endif
virtual void swap_into_for_real(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
};