Skip to content

Commit 49d6f97

Browse files
blevinpixar-oss
authored andcommitted
[hdsi] Lifetime fix found by asan: record the referenced
dirty expression prior to removing it from the collection tables. Reported by the testLightLinkingSceneIndex test under asan, as: =1343067==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c0009bd598 at pc 0x7f2b478c6b23 bp 0x7ffff1bf6350 sp 0x7ffff1bf6340 READ of size 8 at 0x60c0009bd598 thread T0 #0 0x7f2b478c6b22 in std::vector<SdfPathExpression::Op, std::allocator<SdfPathExpression::Op> >::size() const /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_vector.h:919 #1 0x7f2b478c6b22 in std::vector<SdfPathExpression::Op, std::allocator<SdfPathExpression::Op> >::vector(std::vector<SdfPathExpression::Op, std::allocator<SdfPathExpression::Op> > const&) /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_vector.h:555 #2 0x7f2b478c6b22 in SdfPathExpression::SdfPathExpression(SdfPathExpression const&) /depts/tools/build_archive/dev/builds/2379295/inst/fedora-gcc64-opt-asan/pxr/include/pxr/usd/sdf/pathExpression.h:54 #3 0x7f2b478cf89d in std::pair<SdfPathExpression, std::optional<std::pair<SdfPath, TfToken> > >::pair<std::pair<SdfPath, TfToken> const&, true>(SdfPathExpression const&, std::pair<SdfPath, TfToken> const&) /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_pair.h:337 #4 0x7f2b478cf89d in HdsiLightLinkingSceneIndex_Impl::_Cache::ProcessCollection(SdfPath const&, TfToken const&, SdfPathExpression const&) imaging/hdsi/lightLinkingSceneIndex.cpp:156 (Internal change: 2379722)
1 parent 7f94071 commit 49d6f97

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pxr/imaging/hdsi/lightLinkingSceneIndex.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,15 @@ struct _Cache
148148
return;
149149
}
150150

151+
// Mark the old expression as dirty.
152+
// Do this prior to removing the collection below, because
153+
// that will make the table entry referenced by oldExpr expire.
154+
_dirtyState.push_back({oldExpr, collectionId});
155+
151156
// Expression has changed.Remove table entries for the existing
152157
// collection and queue invalidation.
153158
_RemoveCollection(
154159
collectionId, _InvalidationType::DirtyTargetsAndCollection);
155-
156-
_dirtyState.push_back({oldExpr, collectionId});
157-
158160
}
159161

160162
if (IsTrivial(expr)) {

0 commit comments

Comments
 (0)