Fix crashes and instabilities: use-after-free, null derefs, UB, unhandled exceptions#96
Draft
Fix crashes and instabilities: use-after-free, null derefs, UB, unhandled exceptions#96
Conversation
- Fix use-after-free in TracksDirectIORunnable::run() (deleted pointers used after delete) - Fix logic bug in PhongImageViewer comparing variable to itself instead of other - Add null checks for _sfmData in MSfMData::getUrlFromViewId() and getViewsIds() - Guard against division by zero in FloatImageViewer::updatePaintNode() - Fix signed integer overflow (UB) in ImageCache::cleanup() - Add null check in FloatTexture::isValid() and setImage() - Initialize _idView in Surface.hpp to prevent undefined behavior - Replace throw in Q_INVOKABLE MViewStats functions with qWarning + return - Add exception handling in QtAliceVisionImageIOHandler::read() - Fix cache size unit error in SequenceCache::getRamInfo() (TB -> GB) Agent-Logs-Url: https://github.com/alicevision/QtAliceVision/sessions/4795f35c-99b2-4e57-ab7d-3a42d0b3f9ea Co-authored-by: fabiencastan <153585+fabiencastan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
fabiencastan
April 15, 2026 10:04
View session
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Systematic audit of the codebase for crash-causing bugs and undefined behavior. Found and fixed 11 issues across 10 files.
Critical
TracksDirectIORunnable::run()— pointers deleted on load failure, then dereferenced immediately after:MSfMData::getUrlFromViewId()—_sfmDatadereferenced unconditionallyHigh
PhongImageViewerdimension check is a no-op —responseSourceImage.dim != responseSourceImage.dim(compares to self, always false). Fixed to compare againstresponseNormalImage.dim.MSfMData::getViewsIds()— missing_sfmData/status guardFloatImageViewer::updatePaintNode()— zero-height texture or bounding rectImageCache::cleanup()—INT_MAX + diff; switched to unsigned arithmeticFloatTexture::isValid()andsetImage()—_srcImagenever checkedthrow std::runtime_errorfrom 6Q_INVOKABLEfunctions inMViewStats— uncaught exceptions from QML context crash the app. Replaced withqWarning()+ early return.QtAliceVisionImageIOHandler::read()—readImage()can throwMedium / Low
_idViewinSurface.hpp— initialized toUndefinedIndexTSequenceCache::getRamInfo()— divided by 1024⁴ (TB) instead of 1024³ (GB), reporting cache size 1024× too small