Repository navigation
densify: protect the reference depth-map before loading it in fusion - #1321
Closed
Tobias-Fischer wants to merge 1 commit into
Closed
Tobias-Fischer wants to merge 1 commit into
Tobias-Fischer wants to merge 1 commit into
Conversation
DMapCache::UseImage() loads a depth-map and then ejects the least recently used ones until the cache fits its budget. Both fusion loops marked the reference depth-map as protected (SkipMemoryCheckIdxImage) only after loading it, so the ejection inside UseImage() could release the reference itself if the budget were smaller than that depth-map. Since the fusion budget is floored at one working set (cdcseacave#1309) this should not happen on develop; it is a hardening change. On 2.4.0, where the budget could drop below one depth-map under memory pressure, the same order made DenseFuseDepthMaps() dereference the released reference depth-map. Protect the reference before loading it (and clear the protection when the depth-map turns out to be unreadable). Neighbors loaded afterwards are newer than the reference in the LRU order, so they are kept as well.
Owner
|
Thank you for the excellent diagnosis and the 2.4.0 crash trace. #1324 fixes it inside the cache instead of at the callers: |
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.
DMapCache::UseImage()loads a depth-map and then ejects the least recently used ones until the cache fits its budget. Both fusion loops (FuseDepthMaps,DenseFuseDepthMaps) mark the reference depth-map as protected withSkipMemoryCheckIdxImage()only after loading it, so the ejection insideUseImage()can release the reference itself whenever the budget is smaller than that depth-map.This PR protects the reference before loading it, and clears the protection again when the depth-map turns out to be unreadable. Neighbors loaded afterwards are newer than the reference in the LRU order, so the ejection stops at the reference and keeps them too.
This is a hardening change: I have no reproducer on
develop. Since #1309 the fusion budget is floored at one working set (FusionCacheSetup::Available()), so the budget should never drop below the reference depth-map there. If it ever did, theIsEmpty()check would skip the reference, and its points would be silently missing from the cloud.Where it does happen: 2.4.0. There
GetAvailableMemory()can return a budget of a few MB when free memory is just above the safety margin, and the loop has noIsEmpty()check.DenseFuseDepthMaps()then dereferences the released reference depth-map:It showed up at random on a 24 GB Apple M5 under memory pressure (1 crash in 8 runs). With the cache budget capped to 1 MB through a local debug override it crashed every time; with the same reordering applied to 2.4.0 it no longer crashes, and unconstrained runs are unchanged.
Testing: the equivalent change was built and tested on 2.4.0 (macOS arm64) only. I could not build
developlocally, because the newhalfmeshandTinyEXIFdependencies are not packaged in my environment, so I'm relying on CI for this branch.🤖 Generated with Claude Code