Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch CI up with github #577

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ "ubuntu-latest", "ubuntu-18.04", "macos-11", "macos-12", "freebsd-12.2", "freebsd-13.0" ]
os: [ "ubuntu-latest", "ubuntu-18.04", "ubuntu-20.04", "macos-11", "macos-12", "freebsd-12.2", "freebsd-13.0" ]
build-type: [ Release, Debug ]
# Extra cmake flags. GitHub Actions matrix overloads `include` to mean
# 'add extra things to a job' and 'add jobs'. You can add extra things
Expand All @@ -32,7 +32,9 @@ jobs:
- os: "ubuntu-18.04"
dependencies: "sudo apt install ninja-build"
cmake-flags: "-DSNMALLOC_USE_CXX17=ON"
- os: "ubuntu-latest"
- os: "ubuntu-20.04"
dependencies: "sudo apt install ninja-build"
- os: "ubuntu-latest" # 22.04 at time of writing
dependencies: "sudo apt install ninja-build"
- os: "macos-11"
# The homebrew packages are broken at the moment and error out
Expand Down Expand Up @@ -62,19 +64,32 @@ jobs:
dependencies: "sudo apt install ninja-build"
# Extra build to check using pthread library for destructing local state.
- os: "ubuntu-latest"
variant: "Ubuntu (with pthread destructors)."
variant: "with pthread destructors"
dependencies: "sudo apt install ninja-build"
build-type: Debug
self-host: true
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10"
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On"
# Add an extra element to the matrix that does a build with clang 12
# but doesn't run tests.
- os: "freebsd-13.0"
variant: Clang 12 (Build only)
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++12"
build-only: yes
# Check that we can build specifically with libstdc++
- os: "ubuntu-latest"
variant: Clang 10 libstdc++ (Build only)
variant: "libstdc++ (Build only)"
dependencies: "sudo apt install ninja-build"
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
build-only: yes
# Replay some of the above tests with clang-10 specifically
- os: "ubuntu-20.04"
variant: "clang-10 (with pthread destructors)."
dependencies: "sudo apt install ninja-build"
build-type: Debug
self-host: true
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10"
- os: "ubuntu-20.04"
variant: "clang-10 libstdc++ (Build only)"
dependencies: "sudo apt install ninja-build"
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
build-only: yes
Expand Down Expand Up @@ -114,12 +129,17 @@ jobs:
strategy:
matrix:
# Build just release variant as Debug is too slow.
os: [ "ubuntu-latest"]
build-type: [ Release ]
include:
- os: "ubuntu-latest"
continue-on-error: # Don't class as an error if this fails, until we have a more reliablity.
variant: Clang 10 libc++ (TSan + UBSan)
variant: "libc++ (TSan + UBSan)"
dependencies: "sudo apt install ninja-build"
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-stdlib=\"libc++ -g\" -DSNMALLOC_SANITIZER=undefined,thread"
# Also test specifically with clang-10 (on ubuntu-20.04)
- os: "ubuntu-20.04"
continue-on-error: # Don't class as an error if this fails, until we have a more reliablity.
variant: "clang-10 libc++ (TSan + UBSan)"
dependencies: "sudo apt install ninja-build"
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_CXX_FLAGS=-stdlib=\"libc++ -g\" -DSNMALLOC_SANITIZER=undefined,thread"
# Don't abort runners if a single one fails
Expand Down Expand Up @@ -150,26 +170,31 @@ jobs:
triple: arm-linux-gnueabihf
rtld: ld-linux-armhf.so.3
ld-flavour: lld
host-os: ubuntu-latest
- name: arm64
system-processor: aarch64
triple: aarch64-linux-gnu
rtld: ld-linux-aarch64.so.1
ld-flavour: lld
host-os: ubuntu-latest
- name: ppc64el
system-processor: powerpc64le
triple: powerpc64le-linux-gnu
rtld: ld64.so.2
ld-flavour: lld
# See https://github.com/microsoft/snmalloc/issues/576
host-os: ubuntu-20.04
- name: riscv64
system-processor: riscv64
triple: riscv64-linux-gnu
rtld: ld-linux-riscv64-lp64d.so.1
extra-packages: binutils-riscv64-linux-gnu
ld-flavour: bfd
ld: /usr/bin/riscv64-linux-gnu-ld.bfd
host-os: ubuntu-latest
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ubuntu-latest
runs-on: ${{matrix.host-os}}
name: ${{matrix.build-type}} cross-build for ${{ matrix.arch.triple }}
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions src/snmalloc/ds/aba.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace snmalloc
class ABA
{
std::atomic<T*> ptr = nullptr;
std::atomic_flag lock = ATOMIC_FLAG_INIT;
std::atomic<bool> lock{false};

public:
// This method is used in Verona
Expand All @@ -154,7 +154,7 @@ namespace snmalloc

Cmp read()
{
while (lock.test_and_set(std::memory_order_acquire))
while (lock.exchange(true, std::memory_order_acquire))
Aal::pause();

# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
Expand Down Expand Up @@ -184,7 +184,7 @@ namespace snmalloc

~Cmp()
{
parent->lock.clear(std::memory_order_release);
parent->lock.store(false, std::memory_order_release);
# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
operation_in_flight = false;
# endif
Expand Down
10 changes: 5 additions & 5 deletions src/snmalloc/mem/pooled.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ namespace snmalloc
std::atomic<T*> next{nullptr};
/// Used by the pool to keep the list of all entries ever created.
capptr::Alloc<T> list_next;
std::atomic_flag in_use = ATOMIC_FLAG_INIT;
std::atomic<bool> in_use{false};

public:
void set_in_use()
{
if (in_use.test_and_set())
if (in_use.exchange(true))
error("Critical error: double use of Pooled Type!");
}

void reset_in_use()
{
in_use.clear();
in_use.store(false);
}

bool debug_is_in_use()
{
bool result = in_use.test_and_set();
bool result = in_use.exchange(true);
if (!result)
in_use.clear();
in_use.store(false);
return result;
}
};
Expand Down