Fix misaligned stores in buffer (#1063)

* Fix misaligned read/write to buffer

- causes undefined behavior

* Update run-ci.py

- fix spurious CDash submission failure warning

* Improve run-ci.py support for UBSan

* Relax rocprofv3 summary stats count expectation

* Update CHANGELOG

[ROCm/rocprofiler-sdk commit: 37e0d7efce]
Этот коммит содержится в:
Jonathan R. Madsen
2024-09-10 17:08:57 -05:00
коммит произвёл GitHub
родитель a2c173ea40
Коммит 34c35c26ba
9 изменённых файлов: 60 добавлений и 29 удалений
+8 -6
Просмотреть файл
@@ -75,7 +75,7 @@ struct ring_buffer
void destroy();
/// Request a pointer for writing at least \param n bytes.
void* request(size_t n, bool wrap = true);
void* request(size_t n, size_t align, bool wrap = true);
/// Retrieve a pointer for reading at least \param n bytes.
void* retrieve(size_t n) const;
@@ -174,8 +174,9 @@ ring_buffer::write(Tp* in, std::enable_if_t<std::is_class<Tp>::value, int>)
{
if(in == nullptr || m_ptr == nullptr) return {0, nullptr};
auto _length = sizeof(Tp);
void* _out_p = request(_length);
constexpr auto _length = sizeof(Tp);
constexpr auto _align = alignof(Tp);
void* _out_p = request(_length, _align, true);
if(_out_p == nullptr) return {0, nullptr};
@@ -194,8 +195,9 @@ ring_buffer::write(Tp* in, std::enable_if_t<!std::is_class<Tp>::value, int>)
{
if(in == nullptr || m_ptr == nullptr) return {0, nullptr};
auto _length = sizeof(Tp);
void* _out_p = request(_length);
constexpr auto _length = sizeof(Tp);
constexpr auto _align = alignof(Tp);
void* _out_p = request(_length, _align, true);
if(_out_p == nullptr) return {0, nullptr};
@@ -214,7 +216,7 @@ ring_buffer::request(bool wrap)
{
if(m_ptr == nullptr) return nullptr;
return reinterpret_cast<Tp*>(request(sizeof(Tp), wrap));
return reinterpret_cast<Tp*>(request(sizeof(Tp), alignof(Tp), wrap));
}
//
template <typename Tp>