Skip to content

Fix crash when containing object is destroyed during task inventory r… - #6321

Open
soapyf wants to merge 1 commit into
secondlife:developfrom
soapyf:fix/task-inventory-rename-crash
Open

soapyf wants to merge 1 commit into
secondlife:developfrom
soapyf:fix/task-inventory-rename-crash

Conversation

@soapyf

@soapyf soapyf commented Sep 15, 2026

Copy link
Copy Markdown

Description

This PR fixes a Crash-to-Desktop (Access Violation 0xC0000005) that occurs when an in-world object is destroyed (via llDie(), temporary expiration, or deletion) while a user is actively renaming an item inside its task inventory (Contents tab).

Context & Root Cause

When the containing object is destroyed, LLPanelObjectInventory::clearContents() queues the view for deletion and nulls mFolders, but leaves keyboard focus on the active inline text editor (mRenamer). During deferred destruction in LLMortician, LLFolderView::~LLFolderView() clears mViewModel = NULL. Subsequent base class destructors then release keyboard focus from mRenamer, which triggers commitRename() -> arrange() -> getFolderViewModel()->sort(). Because mViewModel was already cleared, this causes an immediate null-pointer dereference on a half-destructed view.

Changes

  • Added LLFolderView::cancelRenaming(): Disables commit_on_focus_lost, disconnects top-lost signals, removes the popup from LLUI, and cleanly releases keyboard focus via gFocusMgr.
  • Destruction Cleanup: Explicitly invokes cancelRenaming() in ~LLFolderView(), deleteAllChildren(), and LLPanelObjectInventory::clearContents().
  • Dangling Handler Guard: Clears LLEditMenuHandler::gEditMenuHandler before mFolders is nulled in LLPanelObjectInventory.
  • Item Extraction Handling: Cancels active renaming if the item being destroyed or extracted from a folder is currently being renamed.
  • Defensive Checks: Adds null checks for mViewModel in finishRenamingItem() and commitRename() to ensure arrange() is never invoked against a dead view model.

Related Issues

  • Please link to a relevant GitHub issue for additional context.
    • Bug Fix: Link to an issue that includes reproduction steps and testing guidance.
    • Feature/Enhancement: Link to an issue with a write-up, rationale, and requirements.

Issue Link: Closes #6320


Checklist

Please ensure the following before requesting review:

  • I have provided a clear title and detailed description for this pull request.
  • If useful, I have included media such as screenshots and video to show off my changes.
  • The PR is linked to a relevant issue with sufficient context.
  • I have tested the changes locally and verified they work as intended.
  • All new and existing tests pass.
  • Code follows the project's style guidelines.
  • Documentation has been updated if needed.
  • Any dependent changes have been merged and published in downstream modules
  • I have reviewed the contributing guidelines.

Additional Notes

  • Tested and verified on Windows 64-bit (Visual Studio 2022).
  • Verified by reproducing the crash using an in-world scripted object with llDie() while renaming an inventory item inside its Contents tab, and confirming that with this fix applied the rename aborts cleanly with no crash or UI lockup.
  • This fix has also been running and validated in viewer forks without any regressions.

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…ename

When an in-world object is destroyed (via llDie, temp expiration, or deletion)
while an item inside its Contents tab is being renamed, the viewer crashes with
an Access Violation (0xC0000005) during LLMortician teardown.

Root Cause:
- LLPanelObjectInventory::clearContents() queued mScroller for deletion and nulled
  mFolders without canceling the active renamer or releasing keyboard focus.
- During destruction, LLFolderView::~LLFolderView() cleared mViewModel to NULL.
- When base view destructors released focus from mRenamer (LLLineEditor),
  commit_on_focus_lost triggered onCommit() -> commitRename() -> arrange().
- arrange() attempted to call getFolderViewModel()->sort(this) while mViewModel
  was NULL, resulting in an immediate NULL-pointer dereference on a half-dead view.
- LLEditMenuHandler::gEditMenuHandler was also left pointing to the destroyed mFolders.

Fixes:
- Added LLFolderView::cancelRenaming() to disconnect callbacks, disable
  commit-on-focus-lost, remove the popup, and release focus via gFocusMgr.
- Called cancelRenaming() in LLFolderView::~LLFolderView() and deleteAllChildren().
- Added defensive null checks for mViewModel in finishRenamingItem() and commitRename().
- In LLPanelObjectInventory (clearContents, deleteAllChildren, ~LLPanelObjectInventory),
  cancel renaming on mFolders and clear gEditMenuHandler before mFolders is nulled.
- In LLFolderViewItem::destroyView() and LLFolderViewFolder::extractItem(), cancel
  active renaming if the item being destroyed/extracted is currently being renamed.
@soapyf
soapyf force-pushed the fix/task-inventory-rename-crash branch from 0f999d4 to 279f3fb Compare September 15, 2026 00:59
@soapyf

soapyf commented Sep 15, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

Crash to Desktop when containing object is destroyed while renaming inventory item

1 participant