Skip to content

Backport VDBObject fix - #1574

Merged
ivanimanishi merged 2 commits into
ImageEngine:RB-10.5from
ivanimanishi:backportVDBObjectFix
Oct 22, 2026
Merged

ivanimanishi merged 2 commits into
ImageEngine:RB-10.5from
ivanimanishi:backportVDBObjectFix

Conversation

@ivanimanishi

Copy link
Copy Markdown
Member

Fixes

  • VDB : Mitigated lack of thread safety in hash()

johnhaddon and others added 2 commits October 22, 2026 15:44
This made lots of interesting sequences of events possible - here's one :

1. Thread A sees `m_hashValid == false` and starts to compute the hash.
2. Thread B also sees `m_hashValid == false` and also starts to compute the hash.
3. Threads A and B merrily stomp over `m_hash` concurrently, so the result won't be deterministic. There are further problems though...
4. Thread A finishes stomping and sets `m_hashValid = true`. Thread B continues stomping.
5. Threads C, D, E etc see `m_hashValid == true` and read whatever the current value of `m_hash` is - all getting different values from different stages of thread B's stomping.

This was causing instanced in-memory VDBS to lose their instancing when exported to Arnold, because each instance got a different random version of the hash.

This is mitigated by computing the hash in a temporary variable before assigning it. This isn't a full fix though, because the compiler _could_ reorder `m_hashValid = true` before `m_hash = h` from the point of view of a reading thread. Solving that needs some form of synchronisation (mutex, call_once etc), which we can't do without an ABI break.
@ivanimanishi
ivanimanishi merged commit 2bbccb9 into ImageEngine:RB-10.5 Oct 22, 2026
3 of 5 checks passed
@ivanimanishi
ivanimanishi deleted the backportVDBObjectFix branch October 22, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants