bitwizeshift / bitwizeshift/Alloy

Enable Ubuntu sanitizers on CI builds

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Complexity: Medium Priority: High Status: Available Type: Bug Report Type: Enhancement
Dominant language
C++
Stars
12
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [x] I did not find a duplicate of this feature request in the Github Issues section.

----------

### Description

This feature is to enable sanitizers on the Ubuntu build, which requires some code-changes to fix.

The current infrastructure is in-place, but failing to run correctly due to `new` and `delete` usages in
the standard-library. It is detecting `::operator new (std::size_t, std::align_t)` from `alloy::core::allocator`
as not being the same alignment used in `::operator delete(std::size_t, std::align_t)`:

```
object passed to delete has wrong type:
alignment of the allocated type: default-aligned;
alignment of the deallocated type: 16 bytes.
#0 0x4e6062 in operator delete(void*, std::align_val_t) (/home/runner/work/Alloy/Alloy/build/lib/alloy-core/test/alloy-core-test+0x4e6062)
#1 0x53cfee in alloy::core::allocator::default_resource::do_deallocate(void*, unsigned long, std::align_val_t) /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/memory/allocator.hpp:990:3
#2 0x5fa98c in alloy::core::memory_resource::deallocate(void*, unsigned long, std::align_val_t) /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/memory/memory_resource.hpp:268:10
#3 0x5fa4c4 in alloy::core::allocator::deallocate_bytes(void*, unsigned long, std::align_val_t) /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/memory/allocator.hpp:532:22
#4 0x5fa460 in alloy::core::stl_allocator_adapter::deallocate(std::byte*, unsigned long) /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/memory/allocator.hpp:1045:22
#5 0x5fa424 in std::allocator_traits >::deallocate(alloy::core::stl_allocator_adapter&, std::byte*, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/alloc_traits.h:341:13
#6 0x5fa3ea in std::_Vector_base >::_M_deallocate(std::byte*, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:354:4
#7 0x5fa2fe in std::_Vector_base >::~_Vector_base() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:335:2
#8 0x5fa181 in std::vector >::~vector() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:683:7
#9 0x5fa0c7 in alloy::core::explicitly_copyable > >::~explicitly_copyable() /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/utilities/explicitly_copyable.hpp:59:9
#10 0x5f9334 in alloy::core::packed_buffer::~packed_buffer() /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/include/alloy/core/memory/packed_buffer.hpp:61:24
#11 0x5ea00f in alloy::core::test::(anonymous namespace)::____C_A_T_C_H____T_E_S_T____3() /home/runner/work/Alloy/Alloy/build/../lib/alloy-core/test/src/alloy/core/memory/packed_buffer.test.cpp:52:1
```

It's not entirely clear what could be causing this discrepancy. This fails with both clang and gcc on Ubuntu, but does not appear to occur on mac -- suggesting that this may either be a variation between `libc++` and `libstdc++`, or potentially that this is undefined behavior that is detected in different versions of the compiler.

At any rate, this issue needs to be investigated and fixed before sanitizers can be enabled.

Marking this as both an enhancement _and_ bug report, since there is likely a fix required here.

Contributor guide

Open the contributing guide

Research direction

Start with the Ubuntu sanitizer CI configuration and reproduce the failure in lib/alloy-core/test/src/alloy/core/memory/packed_buffer.test.cpp. Trace the allocation and deallocation paths in lib/alloy-core/include/alloy/core/memory/allocator.hpp and memory_resource.hpp, using the reported alignment diagnostic as a guide. Done means the packed_buffer test passes under both GCC and Clang sanitizers and Ubuntu sanitizers can be enabled in CI.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
ci-cd, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.