delve/pkg
Alessandro Arzilli bf627d0f7d
proc: fix TestCondBreakpointWithFrame flakes on 1.22rc1 (#3624)
The flake manifests as an error where the variable i can not be found in
frame 1 and happens in go1.22rc1 between 0.1% and 0.5% of the time (it is highly dependent on CPU contention)
This problem is caused by the new code in evalop.PushLocal referencing the
stale value of SelectedGoroutine. This happens because:

-  evalop.PushLocal calls ConvertEvalScope
- ConvertEvalScope calls FindGoroutine
- FindGoroutine checks the value of selectedGoroutine

When breakpoint conditions are evaluated both the value of selectedGoroutine
and currentThread are stale because we can only set their definitive value
*after* all breakpoint conditions have been evaluated.

The fact that it only happens in 1.22rc1 is coincidental, it's probably
caused by the fact that 1.22rc1 migrates goroutines between threads more in
this particular circumstance.

This commit fixes the problem in two ways:

1. selectedGoroutine and currentThread are given temprorary non-stale values
   before breakpoint conditions are evaluated
2. evalop.PushLocal is changed so it takes a stack trace of the current
   thread rather than resolving it through the selected goroutine.

Either one would suffice however I think we should do both, (2) ensures that
the runtime.frame(n).var will work even if the current thread is not running
any goroutine and (1) ensures that we don't accidentally reference a stale
selectedGoroutine in the future.
2024-01-10 06:53:16 -08:00
..
astutil proc: when stepping set condition on thread ID if there is no curg (#3475) 2023-08-21 12:30:56 -07:00
config pkg,service/dap: use switch instead of ifs (#3576) 2023-11-22 09:07:08 -08:00
dwarf pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
elfwriter pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
gobuild all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
goversion goversion: include pre-releases in VersionAfterOrEqual check (#3607) 2023-12-26 10:15:43 -08:00
internal/gosym pkg/proc: use gore to obtain info from stripped binaries (#3577) 2023-11-23 09:12:10 +01:00
locspec pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
logflags all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
proc proc: fix TestCondBreakpointWithFrame flakes on 1.22rc1 (#3624) 2024-01-10 06:53:16 -08:00
terminal terminal: add paging to print, vars, args and locals (#3620) 2024-01-09 14:13:37 -08:00
version *: release version 1.22.0 (#3606) 2023-12-29 14:48:07 -08:00