Added ASan/UBSan to CI, and fixed issues it found. (#445)

This commit is contained in:
Branimir Karadžić
2026-10-05 08:55:08 -07:00
committed by GitHub
parent 9521d0b5e2
commit 09cf98d55c
11 changed files with 154 additions and 32 deletions

View File

@@ -247,9 +247,6 @@ namespace bx
/// Default constructor. Constructs an empty bit array.
BitArrayBaseT();
/// Destructor. Releases storage.
~BitArrayBaseT();
/// Constructs a bit array by copying from a bit array view.
///
/// @param[in] _src Source bit array view to copy from.

View File

@@ -251,11 +251,17 @@ namespace bx
template<typename StorageT>
inline void BitArrayBaseT<StorageT>::set(const BitArrayViewBase& _src)
{
if (this != &_src)
if (this == &_src)
{
this->setCount(_src.getCount() );
return;
}
const uint32_t sizeInBytes = min(this->getCapacity(), _src.getCapacity() ) / 8;
this->setCount(_src.getCount() );
const uint32_t sizeInBytes = min(this->getCapacity(), _src.getCapacity() ) / 8;
if (0 != sizeInBytes)
{
bx::memCopy(this->m_ptr, _src.getPtr(), sizeInBytes);
}
}
@@ -278,12 +284,6 @@ namespace bx
MutableBitArrayView::set(_beginBit, _endBit, _value);
}
template<typename StorageT>
inline BitArrayBaseT<StorageT>::~BitArrayBaseT()
{
this->clear();
}
template<typename StorageT>
template<typename StorageU>
inline BitArrayBaseT<StorageT>& BitArrayBaseT<StorageT>::operator=(const BitArrayBaseT<StorageU>& _rhs)
@@ -400,7 +400,6 @@ namespace bx
{
if (NULL != this->m_storage.getAllocator() )
{
this->clear();
this->m_storage.setCapacity(0, 0);
}

View File

@@ -444,7 +444,10 @@ BX_FP_PRECISE_BEGIN()
const float scaled = _a * (2.0f*kInvPi);
const float real = floor(scaled);
const float xx = _a - real * kPiHalf;
const int32_t bits = int32_t(real) & 3;
const int32_t bits = isFinite(real)
? int32_t(mod(real, 4.0f) ) & 3
: 0
;
constexpr float kSinC2 = -0.16666667163372039794921875f;
constexpr float kSinC4 = 8.333347737789154052734375e-3f;
@@ -702,6 +705,18 @@ BX_FP_PRECISE_BEGIN()
return 0.0f;
}
constexpr float expMax = log(kFloatLargest);
if (_a >= expMax)
{
return kFloatInfinity;
}
if (isNan(_a) )
{
return _a;
}
constexpr float kExpC0 = 1.66666666666666019037e-01f;
constexpr float kExpC1 = -2.77777777770155933842e-03f;
constexpr float kExpC2 = 6.61375632143793436117e-05f;

View File

@@ -246,7 +246,12 @@ namespace bx
int64_t remainder = m_size-m_pos;
int32_t size = int32_t(max<int64_t>(0, min<int64_t>(_size, remainder, INT32_MAX) ) );
memCopy(&m_data[m_pos], _data, size);
if (0 < size)
{
memCopy(&m_data[m_pos], _data, size);
}
m_pos += size;
m_top = max(m_top, m_pos);
if (size != _size)

View File

@@ -856,6 +856,9 @@ BX_FP_PRECISE_BEGIN()
const Ty near_result = simd_f32_add(_a, one);
const Ty exp_min = simd_splat<Ty>(-87.33654475f);
const Ty clamp_mask = simd_f32_cmple(_a, exp_min);
const Ty exp_max = simd_splat<Ty>(88.72283905f);
const Ty inf = simd_splat<Ty>(kFloatInfinity);
const Ty inf_mask = simd_f32_cmpge(_a, exp_max);
const Ty kC0 = simd_splat<Ty>( 1.66666666666666019037e-01f);
const Ty kC1 = simd_splat<Ty>(-2.77777777770155933842e-03f);
const Ty kC2 = simd_splat<Ty>( 6.61375632143793436117e-05f);
@@ -887,7 +890,8 @@ BX_FP_PRECISE_BEGIN()
const Ty ikk = simd_f32_ftoi_trunc(kk);
const Ty raw = simd_f32_ldexp_ni(tmp6, ikk);
const Ty rc = simd_selb(clamp_mask, zero, raw);
const Ty result = simd_selb(near_mask, near_result, rc);
const Ty ri = simd_selb(inf_mask, inf, rc);
const Ty result = simd_selb(near_mask, near_result, ri);
return result;
}