Files
TheRock/compiler/amd-llvm/compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

80 lines
2.1 KiB
C++

// RUN: %clangxx_msan %s -O0 -fsanitize-memory-use-after-dtor -o %t && %run %t
// RUN: %clangxx_msan %s -O1 -fsanitize-memory-use-after-dtor -o %t && %run %t
// RUN: %clangxx_msan %s -O2 -fsanitize-memory-use-after-dtor -o %t && %run %t
// RUN: %clangxx_msan %s -DCVPTR=1 -O2 -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CVPTR
// RUN: %clangxx_msan %s -DEAVPTR=1 -O2 -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=EAVPTR
// RUN: %clangxx_msan %s -DEDVPTR=1 -O2 -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=EDVPTR
// Expected to quit due to invalid access when invoking
// function using vtable.
class A {
public:
int x;
virtual ~A() {
// Should succeed
this->A_Foo();
}
virtual void A_Foo() {}
};
class B : public virtual A {
public:
int y;
virtual ~B() {}
virtual void A_Foo() {}
};
class C : public B {
public:
int z;
};
class D {
public:
int w;
~D() {}
virtual void D_Foo() {}
};
class E : public virtual A, public virtual D {
public:
int u;
~E() {}
void A_Foo() {}
};
int main() {
// Simple linear inheritance
C *c = new C();
c->~C();
// This fails
#ifdef CVPTR
c->A_Foo();
// CVPTR: Virtual table ptr was destroyed
// CVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
// CVPTR: {{#1 0x.* in ~C .*cpp:}}[[@LINE-28]]:
// CVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
#endif
// Multiple inheritance, so has multiple vtables
E *e = new E();
e->~E();
// Both of these fail
#ifdef EAVPTR
e->A_Foo();
// EAVPTR: Virtual table ptr was destroyed
// EAVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
// EAVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-25]]:
// EAVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
#endif
#ifdef EDVPTR
e->D_Foo();
// EDVPTR: Virtual table ptr was destroyed
// EDVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
// EDVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-33]]:
// EDVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-15]]:
#endif
}