Skip to content

fix(datagrid): crash adding a row while a cell overlay is open (#1378)#1379

Merged
datlechin merged 1 commit into
mainfrom
fix/1378-overlay-raise-crash
May 22, 2026
Merged

fix(datagrid): crash adding a row while a cell overlay is open (#1378)#1379
datlechin merged 1 commit into
mainfrom
fix/1378-overlay-raise-crash

Conversation

@datlechin
Copy link
Copy Markdown
Member

Fixes #1378.

Problem

Adding a row (Cmd+Shift+N) crashes when a cell editor or value viewer overlay is open. The trace is a Swift exclusive-access-to-memory violation (swift_beginAccess -> AccessSet::insert -> _swift_runtime_on_report), not a stack overflow.

Cause

KeyHandlingTableView.didAddSubview passed the reentrancy guard as inout (flag: &isRaisingOverlayEditor), which holds an exclusive access for the whole call. Inside, raiseToFront() calls addSubview, which synchronously re-enters didAddSubview and tries to take a second overlapping access to the same property. The runtime traps. The guard !flag never gets to run because the conflict is detected when the inout argument is formed.

Regression from #1341, which refactored the prior inline guard into an inout helper. The version before that used a direct instance-property guard, which does not conflict.

Fix

Drop the inout parameter. Use one isRaisingOverlay guard hoisted to the top of didAddSubview, reset with defer. Bool reads and writes are instantaneous accesses, so the reentrant call short-circuits cleanly. Editor and viewer are mutually exclusive (each show dismisses the other), so a single guard is correct.

Test

KeyHandlingTableViewOverlayTests installs an active overlay, adds another subview to force the re-raise path, and asserts the overlay ends on top. This path traps before the fix and passes after. Verified locally with ** TEST SUCCEEDED **.

Not included

The reporter also mentioned "the plus button to add a new row is not visible." That has no trace and is not explained by this crash. Tracking separately.

@datlechin datlechin merged commit 495466a into main May 22, 2026
2 checks passed
@datlechin datlechin deleted the fix/1378-overlay-raise-crash branch May 22, 2026 07:30
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.

App Crash on Add new row keyboard shortcut

1 participant