Commit 1f15cf55 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'asan' into 'master'

[Makefile] Add asan(-test) targets

See merge request i4/manycore/emper!398
parents 1ab6b42a 37aebe3e
......@@ -83,6 +83,18 @@ lto:
EMPER_B_LTO=true \
BUILDDIR="build-$@"
.PHONY: asan
asan:
rm -f build
$(MAKE) build \
EMPER_LOG_LEVEL="Info" \
EMPER_B_SANITIZE=address \
BUILDDIR="build-$@"
.PHONY: asan-test
asan-test: asan
meson test -C build-asan
.PHONY: fast-static-analysis
fast-static-analysis: all check-format check-license doc
......
......@@ -175,7 +175,16 @@ class AbstractSemaphoreWorkerSleepStrategy
AbstractSemaphoreWorkerSleepStrategy(Runtime& runtime, workerid_t workerCount)
: workerCount(workerCount), stats(runtime) {
if constexpr (useGenericNotifySpecificImpl) {
states = new (std::align_val_t(CACHE_LINE_SIZE)) std::atomic<SleeperState>[workerCount];
// If ASAN is used, then it will rightfully complain about a
// mismatched aligned-new with and unaligned-delete
// below. However if we use the aligned-delete, then we get, at
// least on my machine, an "unused argumetn" error (see comment
// below).
states = new
#ifndef __SANITIZE_ADDRESS__
(std::align_val_t(CACHE_LINE_SIZE))
#endif
std::atomic<SleeperState>[workerCount];
}
if constexpr (semNeedsInit) {
......@@ -183,7 +192,12 @@ class AbstractSemaphoreWorkerSleepStrategy
}
}
~AbstractSemaphoreWorkerSleepStrategy() { delete[] states; }
~AbstractSemaphoreWorkerSleepStrategy() {
// This should actually use an aligned delete, i.e.,
// delete[](std::align_val_t(CACHE_LINE_SIZE), states);
// however, this throws "unused first argument" errors when compiling.
delete[] states;
}
[[nodiscard]] inline auto getSleeping() const -> long { return wakeupSem.getValue(); }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment