Fix LT-21598: Crash deleting from Bulk Edit Entries#380
Conversation
Bulk deleting lexical entries that participate in a lexical relation could crash with a NullReferenceException. With corrupt data (a lost incoming- reference index, not repaired by Find and Fix) a LexReference can still list a target that has already been deleted. During the deletion cascade, the LexReference removal side effects operated on those already-deleted objects and dereferenced their cleared cache. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hahn-kev
left a comment
There was a problem hiding this comment.
Looks good to me, the tests reproduce the issue and fail without the fix.
One thing I did notice, that may effect something, is that the order in which UpdateMinimalLexReferences and UpdateLexEntryReferences is called has changed. The old version would call UpdateLex first, then UpdateMinimal however the new version changes that. I'm not sure if this was intentional but we might consider putting it back to how it was.
mark-sil
left a comment
There was a problem hiding this comment.
Thanks Kevin, I restored the order.
@mark-sil made 1 comment.
Reviewable status: 0 of 3 files reviewed, all discussions resolved.
hahn-kev
left a comment
There was a problem hiding this comment.
looks good to me, I don't have the full context of this and I'm not sure about the original issue though.
Summary
Bulk deleting lexical entries that participate in a lexical relation could crash with a
NullReferenceException(LT-21598). The attached project (Puntipi-Luritja) has corrupt data — a lost incoming-reference index, not repaired by Find and Fix — so aLexReferencecan still list a target that has already been deleted. During the deletion cascade,LexReference's removal side effects operated on those already-deleted objects and dereferenced their cleared cache.Changes (
LexReferenceinOverridesLing_Lex.cs)UpdateMinimalLexReferencesskips targets that are no longer valid.RemoveObjectSideEffectsInternalonly updates the removed object's back-reference virtual properties (LexEntryReferences/LexSenseReferences/DateModified) while it is still valid; the remaining valid targets are still refreshed viaUpdateMinimalLexReferences.Testing
LingTests.cs, each verified to fail at the exact reported stack without its fix.🤖 Generated with Claude Code
This change is