Skip to content

LLDB: fixes for two issues from the #2527 review - #2627

Merged
bfiete merged 2 commits into
beefytech:masterfrom
robknopf:pr/lldb-review-fixes
Nov 30, 2026
Merged

bfiete merged 2 commits into
beefytech:masterfrom
robknopf:pr/lldb-review-fixes

Conversation

@robknopf

Copy link
Copy Markdown
Contributor

Fixes for two issues from the #2527 review.

Autocomplete could run property getters. DoEvaluate set mEvalAllowCalls / mEvalAllowProperties and left them set. Autocomplete (and memory-watch setup) resolve paths outside an evaluation, so after any evaluation that allowed calls, typing obj.Prop. in the watch window ran get__Prop in the target. The flags are now scoped to DoEvaluate with SetAndRestoreValue.
Test: DbgAutocompleteGetters. A counting getter goes from 1 to 2 after autocomplete without the fix, and stays at 1 with it.

Hot swap freed images that data fixups still referenced. HotCleanupImages freed any old hot image with no references from symbols, patched entries, registers or stacks. But data fixups write pointers into the original tables that point back into the image they came from: merged vtable entries, copied type data, and the string literal table link that String.CheckLiterals / Intern walk. Once that image was freed and its memory reused by a later load, the literal chain was corrupt. Images that a fixup applied from are now pinned. This keeps each compile's vdata object, roughly 28KB per hot compile on the test project. Code-only images are still freed.
Test: HotSwap_FreedImages. Six compiles that swap between existing literals, ending in SIGSEGV in Intern without the fix.

Test1 suite: 52/52 on Linux.

DoEvaluate set mEvalAllowCalls and mEvalAllowProperties from the evaluation's
flags and never cleared them. Autocomplete resolves the target of a member
access through EvaluateBeefPath outside of any evaluation, so it ran property
getters whenever the last evaluation had been allowed to make calls. After an
Immediate panel evaluation, typing 'obj.Prop.m' in the Watch or Immediate panel
called Prop's getter in the debuggee on every keystroke.

The two flags now only hold for the duration of DoEvaluate (SetAndRestoreValue),
which a pending evaluation's continuation goes through as well.

DbgAutocompleteGetters counts a getter's calls: autocomplete before any
evaluation leaves it alone, and without this it ran after one that made calls.
Found by bfiete's review of beefytech#2527.
HotCleanupImages frees an earlier hot load's images once no hot symbol,
patched entry, register or stack word points into them. It never saw what
HotApplyDataFixups wrote into the original tables, which can point back into
the image it came from. Each compile's vdata links its string literal table
into the chain the executable's table starts. A compile that adds no new
symbol leaves its vdata image referenced only by that chain, so the next
compile freed it and a later one reused the memory. String.CheckLiterals then
followed the overwritten link, here back into the chain itself, and recursed
until the stack overflowed: Intern() crashed with SIGSEGV.

An image that any data fixup applied from is now pinned and never freed,
which is what Windows does for every hot image. Images that only held
replaced methods are freed as before; the vdata kept is about 28KB per
compile in the test.

HotSwap_FreedImages makes six hot compiles that alternate new literals and
ones the program already has, and crashed on the sixth without this.
Found by bfiete's review of beefytech#2527.
@bfiete
bfiete merged commit f45a2de into beefytech:master Nov 30, 2026
5 checks passed
@robknopf
robknopf deleted the pr/lldb-review-fixes branch November 30, 2026 16:35
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