Repository navigation
Fix BreakpointCondition crash for unregistered breakpoint numbers - #1282
Merged
Merged
Conversation
get_condition/2 crashed the GenServer when no condition was registered under the requested number. The instrumented code can still call check_N/1 after the breakpoint was removed, replaced, or after clear/0 freed the number, which hit elem(1) on nil. get_condition/2 now returns nil for an unregistered number, and the generated check_N/1 functions return false in that case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The debug adapter crashes when the interpreted code calls a breakpoint condition check for a number that is no longer registered:
handle_call({:get_condition, number}, ...)didEnum.find(...) |> elem(1), which fails when no condition with that number exists. This is a race: the instrumented code still callscheck_N/1after the breakpoint was removed or replaced (unregister_conditionfreed the number), or afterclear/0. The GenServer dies and the debuggee'scheck_Ncall fails too.Fix
get_condition/2returnsnilfor an unregistered number (spec updated).check_N/1returnsfalsewhen there is no condition, so the breakpoint does not stop and nothing is logged.Tests
New tests in
apps/debug_adapter/test/breakpoint_condition_test.exscoverget_conditionandcheck_Nfor never-registered, unregistered, and cleared numbers, and assert the GenServer stays alive.cd apps/debug_adapter && mix test test/breakpoint_condition_test.exs: 30 tests, 0 failures.