Files
TheRock/compiler/amd-llvm/compiler-rt/test/asan/TestCases/Darwin/asan-symbolize-templated-cxx.cpp
T
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

64 lines
2.1 KiB
C++

// UNSUPPORTED: ios
// UNSUPPORTED: darwin
// RUN: %clangxx_asan -O0 -g %s -o %t.executable
// RUN: %env_asan_opts="symbolize=0" not %run %t.executable > %t_no_module_map.log 2>&1
// RUN: %asan_symbolize --force-system-symbolizer < %t_no_module_map.log 2>&1 | FileCheck %s
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <functional>
// This test is deliberately convoluted so that there is a function call
// in the stack trace that contains nested parentheses.
template <class CallBackTy>
class IntWrapper {
int value_;
std::function<CallBackTy> callback_;
public:
IntWrapper(int value, std::function<CallBackTy> callback) : value_(value), callback_(callback) {}
int &operator=(const int &new_value) {
value_ = new_value;
callback_(value_);
}
};
using IntW = IntWrapper<void(int)>;
IntW *a;
template <class T>
void writeToA(T new_value) {
// CHECK: heap-use-after-free
// NOTE: atos seems to emit the `void` return type here for some reason.
// CHECK: #{{[0-9]+}} 0x{{.+}} in {{(void +)?}}writeToA<IntWrapper<void{{ *}}(int)>{{ *}}>(IntWrapper<void{{ *}}(int)>) asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
*a = new_value;
}
extern "C" void callback(int new_value) {
printf("new value is %d\n", new_value);
}
template <class T, class V>
struct Foo {
std::function<T> call;
Foo(std::function<T> c) : call(c) {}
void doCall(V new_value) {
// CHECK: #{{[0-9]+}} 0x{{.+}} in Foo<void (IntWrapper<void{{ *}}(int)>),{{ *}}IntWrapper<void{{ *}}(int)>{{ *}}>::doCall(IntWrapper<void{{ *}}(int)>) asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
call(new_value);
}
};
int main() {
a = new IntW(0, callback);
assert(a);
// Foo<void(IntWrapper<void(int)>)>
// This type is deliberately convoluted so that the demangled type contains nested parentheses.
// In particular trying to match parentheses using a least-greedy regex approach will fail.
Foo<void(IntW), IntW> foo(writeToA<IntW>);
delete a;
// CHECK: #{{[0-9]+}} 0x{{.+}} in main asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
foo.doCall(IntW(5, callback)); // BOOM
return 0;
}