Skip to content

#3814 Handle bad_allocs in unpackVolumeFaces - #6112

Open
akleshchev wants to merge 1 commit into
developfrom
andreyk/viewer_2814_20
Open

#3814 Handle bad_allocs in unpackVolumeFaces#6112
akleshchev wants to merge 1 commit into
developfrom
andreyk/viewer_2814_20

Conversation

@akleshchev

Copy link
Copy Markdown
Contributor

Handle bad_allocs in unpackVolumeFaces

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens LLVolume::unpackVolumeFaces() against memory-allocation failures and implausible compressed payload sizes while unpacking mesh volume faces, aiming to avoid crashes and improve resiliency during mesh streaming/decode.

Changes:

  • Added a compressed-size sanity check (rejecting non-positive or very large inputs) before attempting unzip/decode.
  • Wrapped unzip + decode in try/catch to handle std::bad_alloc, std::exception, and unknown exceptions with logging and safer failure behavior.
  • Introduced mainloop WorkQueue posting for the small-mesh OOM path to surface an OOM user warning / fatal on the main loop.
Suppressed comments (1)

indra/llmath/llvolume.cpp:2416

  • main_queue->post() can fail (e.g. if the queue is closed) and the return value is currently ignored, which can drop the out-of-memory handler in the “small mesh” path. Please check the return value and fall back to a local warning when posting fails.
                const LLUUID mesh_id_copy = mesh_id; // capture by value for the lambda
                main_queue->post([mesh_id_copy, size]()
                {
                    LLError::LLUserWarningMsg::showOutOfMemory();
                    LL_ERRS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id_copy

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread indra/llmath/llvolume.cpp
Comment on lines +2339 to +2346
const LLUUID mesh_id_copy = mesh_id; // capture by value for the lambda
main_queue->post([mesh_id_copy, size]()
{
LLError::LLUserWarningMsg::showOutOfMemory();
LL_ERRS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id_copy
<< " of compressed size " << size << LL_ENDL;
});
}

@akleshchev akleshchev Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix. But if main_queue is closed, we are shuting down and don't really care, memory will be freed soon.

@akleshchev
akleshchev force-pushed the andreyk/viewer_2814_20 branch from 2fe8fb5 to ee1789b Compare August 11, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants