-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log: fix call depth for go1.12 panics
This PR fixes the following test failure on Linux: ``` $ make test IGNORE_GOVERS=1 PKG=./pkg/util/log --- FAIL: TestCrashReportingPacket (0.20s) --- FAIL: TestCrashReportingPacket/#00 (0.00s) crash_reporting_packet_test.go:155: expected crash_reporting_packet_test.go:85: boom, got testing.go:865: boom --- FAIL: TestCrashReportingPacket/#1 (0.00s) crash_reporting_packet_test.go:155: expected crash_reporting_packet_test.go:93: baam, got testing.go:865: baam FAIL ``` Interestingly this is not quite the same failure noted in #35792, maybe that's MacOS specific? Release note: None
- Loading branch information
Showing
3 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
// +build !go1.12 | ||
|
||
// This file exists to deal with the fact that the call depth during panics | ||
// differs before and after go version 1.12. It holds the correct depth for use | ||
// with go1.11 and prior and carries the appropriate build constraint. | ||
|
||
package log | ||
|
||
// The call stack here is usually: | ||
// - ReportPanic | ||
// - RecoverAndReport | ||
// - panic.go | ||
// - panic() | ||
// so ReportPanic should pop four frames. | ||
const depthForRecoverAndReportPanic = 4 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
// +build go1.12 | ||
|
||
// This file exists to deal with the fact that the call depth during panics | ||
// differs before and after go version 1.12. It holds the correct depth for use | ||
// with go1.12 and later and carries the appropriate build constraint. | ||
|
||
package log | ||
|
||
// The call stack here is usually: | ||
// - ReportPanic | ||
// - RecoverAndReport | ||
// - panic() | ||
// so ReportPanic should pop three frames. | ||
const depthForRecoverAndReportPanic = 3 |
This file contains 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