diff options
author | Hiro <laciferin@gmail.com> | 2023-06-21 23:33:51 +0000 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-06-27 18:21:24 +0000 |
commit | 942c1c12d89a53071ccd883e16d84af2001f2557 (patch) | |
tree | 7c1915b3301c891d0c8fd7d12928de8b1401099f | |
parent | 4ad4128d3c09e24f1e901635bd81ba2db7c46764 (diff) | |
download | go-942c1c12d89a53071ccd883e16d84af2001f2557.tar.gz go-942c1c12d89a53071ccd883e16d84af2001f2557.zip |
runtime: fix trace.Stop deadlock when built with faketime
For #60806
Change-Id: I1ac18a6c7c703a1d6c4cd80f220059ba0be51e09
GitHub-Last-Rev: d300ca3f316d34f5013be43d01a9a473fe3000b2
GitHub-Pull-Request: golang/go#60834
Reviewed-on: https://go-review.googlesource.com/c/go/+/503356
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r-- | src/runtime/trace.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/trace.go b/src/runtime/trace.go index ac80ca2902..a4d50d77a0 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -453,12 +453,17 @@ func StopTrace() { } } + // Wait for startNanotime != endNanotime. On Windows the default interval between + // system clock ticks is typically between 1 and 15 milliseconds, which may not + // have passed since the trace started. Without nanotime moving forward, trace + // tooling has no way of identifying how much real time each cputicks time deltas + // represent. for { trace.endTime = traceClockNow() trace.endTicks = cputicks() trace.endNanotime = nanotime() - // Windows time can tick only every 15ms, wait for at least one tick. - if trace.endNanotime != trace.startNanotime { + + if trace.endNanotime != trace.startNanotime || faketime != 0 { break } osyield() |