CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
// RUN: %clangxx_msan -O0 %s -o %t && %run %t
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <ucontext.h>
|
|
#include <unistd.h>
|
|
|
|
#include <sanitizer/msan_interface.h>
|
|
|
|
namespace {
|
|
|
|
const int kStackSize = 1 << 20;
|
|
char fiber_stack[kStackSize] = {};
|
|
|
|
ucontext_t main_ctx;
|
|
ucontext_t fiber_ctx;
|
|
|
|
void fiber() {
|
|
printf("%s: entering fiber\n", __FUNCTION__);
|
|
|
|
// This fiber was switched into from main. Verify the details of main's stack
|
|
// have been populated by MSAN.
|
|
const void *previous_stack_bottom = nullptr;
|
|
size_t previous_stack_size = 0;
|
|
__msan_finish_switch_fiber(&previous_stack_bottom, &previous_stack_size);
|
|
assert(previous_stack_bottom != nullptr);
|
|
assert(previous_stack_size != 0);
|
|
|
|
printf("%s: implicitly swapcontext to main\n", __FUNCTION__);
|
|
__msan_start_switch_fiber(previous_stack_bottom, previous_stack_size);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// Set up a fiber, switch to it, and switch back, invoking __msan_*_switch_fiber
|
|
// functions along the way. At each step, validate the correct stack addresses and
|
|
// sizes are returned from those functions.
|
|
int main(int argc, char **argv) {
|
|
if (getcontext(&fiber_ctx) == -1) {
|
|
perror("getcontext");
|
|
_exit(1);
|
|
}
|
|
fiber_ctx.uc_stack.ss_sp = fiber_stack;
|
|
fiber_ctx.uc_stack.ss_size = sizeof(fiber_stack);
|
|
fiber_ctx.uc_link = &main_ctx;
|
|
makecontext(&fiber_ctx, fiber, 0);
|
|
|
|
// Tell MSAN a fiber switch is about to occur, then perform the switch
|
|
printf("%s: swapcontext to fiber\n", __FUNCTION__);
|
|
__msan_start_switch_fiber(fiber_stack, kStackSize);
|
|
if (swapcontext(&main_ctx, &fiber_ctx) == -1) {
|
|
perror("swapcontext");
|
|
_exit(1);
|
|
}
|
|
|
|
// The fiber switched to above now switched back here. Tell MSAN that switch
|
|
// is complete and verify the fiber details return by MSAN are correct.
|
|
const void *previous_stack_bottom = nullptr;
|
|
size_t previous_stack_size = 0;
|
|
__msan_finish_switch_fiber(&previous_stack_bottom, &previous_stack_size);
|
|
assert(previous_stack_bottom == fiber_stack);
|
|
assert(previous_stack_size == kStackSize);
|
|
|
|
printf("%s: exiting\n", __FUNCTION__);
|
|
|
|
return 0;
|
|
}
|