[build] Fix undefined behavour sanitizer (#16375)
* [build] Fix integer overflow runtime error for core part Temporarily remove circle ci UBSAN build precondition * [build] Enable all of the ubsans [build] Check runtime error [build] Update UBSAN_OPTION * [build] Add UBSAN blacklist [build] Ignore system libraries [build] Ignore vendor library * [build] Fix implicit conversion runtime error in core * [build] Fix division by zero runtime error * [build] Add unfixed error to ubsan blacklist * [build] Make UBSAN halt on error Revert "Temporary remove build precondition" * [build] Fix division by zero error * [build] Make UBSAN officially work without FIXME prefix * [build] Fix implicit conversion from int64_t to uint64_t * [build] Rename style test json file name * Address review findings
This commit is contained in:
@@ -1275,7 +1275,8 @@ bool OfflineDatabase::evict(uint64_t neededFreeSize, DatabaseSizeChangeStats& st
|
||||
const uint64_t tileChanges = tileQuery.changes();
|
||||
|
||||
// Update current ambient cache size, based on how many bytes were released.
|
||||
newAmbientCacheSize = std::max<int64_t>(newAmbientCacheSize - stats.bytesReleased(), 0u);
|
||||
newAmbientCacheSize = std::max<int64_t>(
|
||||
static_cast<int64_t>(newAmbientCacheSize) - static_cast<int64_t>(stats.bytesReleased()), 0u);
|
||||
|
||||
// The cached value of offlineTileCount does not need to be updated
|
||||
// here because only non-offline tiles can be removed by eviction.
|
||||
@@ -1465,9 +1466,9 @@ uint64_t OfflineDatabase::DatabaseSizeChangeStats::pageSize() const {
|
||||
}
|
||||
|
||||
int64_t OfflineDatabase::DatabaseSizeChangeStats::diff() const {
|
||||
const uint64_t currentSize =
|
||||
pageSize_ * (db->getPragma<int64_t>("PRAGMA page_count") - db->getPragma<int64_t>("PRAGMA freelist_count"));
|
||||
return currentSize - initialSize_;
|
||||
const int64_t currentSize = static_cast<int64_t>(pageSize_) * (db->getPragma<int64_t>("PRAGMA page_count") -
|
||||
db->getPragma<int64_t>("PRAGMA freelist_count"));
|
||||
return currentSize - static_cast<int64_t>(initialSize_);
|
||||
}
|
||||
|
||||
uint64_t OfflineDatabase::DatabaseSizeChangeStats::bytesReleased() const {
|
||||
@@ -1478,7 +1479,7 @@ uint64_t OfflineDatabase::DatabaseSizeChangeStats::bytesReleased() const {
|
||||
void OfflineDatabase::updateAmbientCacheSize(DatabaseSizeChangeStats& stats) {
|
||||
assert(currentAmbientCacheSize);
|
||||
if (currentAmbientCacheSize) {
|
||||
*currentAmbientCacheSize = std::max<int64_t>(*currentAmbientCacheSize + stats.diff(), 0u);
|
||||
*currentAmbientCacheSize = std::max<int64_t>(static_cast<int64_t>(*currentAmbientCacheSize) + stats.diff(), 0u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ PremultipliedImage decodeImage(const std::string& string) {
|
||||
const size_t size = string.size();
|
||||
|
||||
if (size >= 4) {
|
||||
uint32_t magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||
uint32_t magic = (static_cast<uint32_t>(data[0]) << 24) | (static_cast<uint32_t>(data[1]) << 16) |
|
||||
(static_cast<uint32_t>(data[2]) << 8) | static_cast<uint32_t>(data[3]);
|
||||
if (magic == 0x89504E47U) {
|
||||
return decodePNG(data, size);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ Timer::Timer()
|
||||
Timer::~Timer() = default;
|
||||
|
||||
void Timer::start(Duration timeout, Duration repeat, std::function<void()>&& cb) {
|
||||
impl->start(std::chrono::duration_cast<Milliseconds>(timeout).count(),
|
||||
std::chrono::duration_cast<Milliseconds>(repeat).count(),
|
||||
impl->start(static_cast<uint64_t>(std::chrono::duration_cast<Milliseconds>(timeout).count()),
|
||||
static_cast<uint64_t>(std::chrono::duration_cast<Milliseconds>(repeat).count()),
|
||||
std::move(cb));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user