You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using an undefined behaviour sanitizer with RenderTargetPool.cpp:167 reports an issue of unsigned integer undeflow:
if (UTILS_UNLIKELY(mDeepPurgeCountDown-- == 0)) {
mDeepPurgeCountDown = POOL_ENTRY_MAX_AGE;
uint32_t age = mCacheAge - POOL_ENTRY_MAX_AGE;
// remove all entries that are older than CACHE_ENTRY_MAX_AGEauto last = std::remove_if(cache.begin(), cache.end(),
[this, &driver, age](const Entry* entry) {
boolremove = entry->age <= age;
if (remove) {
destroyEntry(driver, entry);
}
returnremove;
});
cache.erase(last, cache.end());
}
In this case mDeepPurgeCountDown (an uint32_t) is zero when this block is reached when it becomes decremented and underflows.
Sanitizer report:
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /filament/filament/src/Camera.cpp:205:23 in
filament/filament/src/RenderTargetPool.cpp:167:9: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'uint32_t' (aka 'unsigned int')
#0 0xf7d904 in filament::RenderTargetPool::gc()
filament/filament/src/RenderTargetPool.cpp:167:9 #1 0xf203fa in filament::details::FRenderer::endFrame()
filament/filament/src/Renderer.cpp:371:9 #2 0xf21aa9 in filament::Renderer::endFrame()
filament/filament/src/Renderer.cpp:460:19
Expected behavior
I am quite sure this is not the desired behaviour. E.g something like this would solve the issue: UTILS_UNLIKELY(mDeepPurgeCountDown == 0 || mDeepPurgeCountDown-- == 0)
Desktop (please complete the following information):
OS: Linux Mint 18
GPU: [NVIDIA GTX 1050]
Backend: [OpenGL]
Additional context
Seems that this happens on shutdown, so it might not actually cause any runtime issues.
The text was updated successfully, but these errors were encountered:
I don't think there is problem here. mDeepPurgeCountDown is tested before being decremented. If it is 0, then it will indeed underflow, but it is immediately reset to POOL_ENTRY_MAX_AGE.
Describe the bug
Using an undefined behaviour sanitizer with RenderTargetPool.cpp:167 reports an issue of unsigned integer undeflow:
In this case mDeepPurgeCountDown (an uint32_t) is zero when this block is reached when it becomes decremented and underflows.
Sanitizer report:
Expected behavior
I am quite sure this is not the desired behaviour. E.g something like this would solve the issue:
UTILS_UNLIKELY(mDeepPurgeCountDown == 0 || mDeepPurgeCountDown-- == 0)
Desktop (please complete the following information):
Additional context
Seems that this happens on shutdown, so it might not actually cause any runtime issues.
The text was updated successfully, but these errors were encountered: