Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(989)

Issue 13367052: code review 13367052: runtime, cmd/gc, cmd/ld: ignore method wrappers in recover (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by rsc
Modified:
11 years, 8 months ago
Reviewers:
dave, iant
CC:
golang-dev, iant
Visibility:
Public.

Description

runtime, cmd/gc, cmd/ld: ignore method wrappers in recover Bug #1: Issue 5406 identified an interesting case: defer iface.M() may end up calling a wrapper that copies an indirect receiver from the iface value and then calls the real M method. That's two calls down, not just one, and so recover() == nil always in the real M method, even during a panic. [For the purposes of this entire discussion, a wrapper's implementation is a function containing an ordinary call, not the optimized tail call form that is somtimes possible. The tail call does not create a second frame, so it is already handled correctly.] Fix this bug by introducing g->panicwrap, which counts the number of bytes on current stack segment that are due to wrapper calls that should not count against the recover check. All wrapper functions must now adjust g->panicwrap up on entry and back down on exit. This adds slightly to their expense; on the x86 it is a single instruction at entry and exit; on the ARM it is three. However, the alternative is to make a call to recover depend on being able to walk the stack, which I very much want to avoid. We have enough problems walking the stack for garbage collection and profiling. Also, if performance is critical in a specific case, it is already faster to use a pointer receiver and avoid this kind of wrapper entirely. Bug #2: The old code, which did not consider the possibility of two calls, already contained a check to see if the call had split its stack and so the panic-created segment was one behind the current segment. In the wrapper case, both of the two calls might split their stacks, so the panic-created segment can be two behind the current segment. Fix this by propagating the Stktop.panic flag forward during stack splits instead of looking backward during recover. Fixes issue 5406.

Patch Set 1 #

Patch Set 2 : diff -r 0a3f59715a28 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 0a3f59715a28 https://code.google.com/p/go/ #

Total comments: 12

Patch Set 4 : diff -r 0a3f59715a28 https://code.google.com/p/go/ #

Patch Set 5 : diff -r 0a3f59715a28 https://code.google.com/p/go/ #

Patch Set 6 : diff -r 0a3f59715a28 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 7 : diff -r 5694c6095fc7 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+394 lines, -84 lines) Patch
M src/cmd/5l/noop.c View 1 2 3 2 chunks +59 lines, -0 lines 0 comments Download
M src/cmd/6l/pass.c View 1 4 chunks +28 lines, -4 lines 0 comments Download
M src/cmd/8l/pass.c View 1 4 chunks +28 lines, -4 lines 0 comments Download
M src/cmd/gc/go.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/gc/pgen.c View 1 2 3 1 chunk +12 lines, -1 line 0 comments Download
M src/cmd/gc/subr.c View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/ld/textflag.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
M src/pkg/reflect/asm_386.s View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/reflect/asm_amd64.s View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/reflect/asm_arm.s View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
src/pkg/reflect/value.go View 1 2 3 2 chunks +8 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_386.s View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/asm_amd64.s View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/panic.c View 1 1 chunk +18 lines, -60 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 3 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/stack.c View 1 3 chunks +12 lines, -1 line 0 comments Download
M test/recover.go View 1 2 3 4 5 4 chunks +212 lines, -4 lines 0 comments Download

Messages

Total messages: 8
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 8 months ago (2013-09-12 02:35:45 UTC) #1
iant
In the CL description, s/callss/calls/. Does the right thing happen when using reflect.MakeFunc or v.Method(i).Interface() ...
11 years, 8 months ago (2013-09-12 03:14:09 UTC) #2
rsc
Looking into reflecty test cases now... https://codereview.appspot.com/13367052/diff/6001/src/cmd/5l/noop.c File src/cmd/5l/noop.c (right): https://codereview.appspot.com/13367052/diff/6001/src/cmd/5l/noop.c#newcode275 src/cmd/5l/noop.c:275: if(cursym->text->reg & WRAPPER) ...
11 years, 8 months ago (2013-09-12 16:10:42 UTC) #3
rsc
PTAL The cases you mentioned were of course broken. Now they have tests and work. ...
11 years, 8 months ago (2013-09-12 16:31:20 UTC) #4
iant
LGTM I can't claim to fully grasp what is happening in the runtime code. At ...
11 years, 8 months ago (2013-09-12 16:47:23 UTC) #5
rsc
https://codereview.appspot.com/13367052/diff/21001/src/pkg/reflect/value.go File src/pkg/reflect/value.go (right): https://codereview.appspot.com/13367052/diff/21001/src/pkg/reflect/value.go#newcode501 src/pkg/reflect/value.go:501: // NOTE: This function must be marked as a ...
11 years, 8 months ago (2013-09-12 16:55:02 UTC) #6
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=84e8898f7eca *** runtime, cmd/gc, cmd/ld: ignore method wrappers in recover Bug #1: ...
11 years, 8 months ago (2013-09-12 18:00:22 UTC) #7
dave_cheney.net
11 years, 8 months ago (2013-09-12 22:47:25 UTC) #8
Message was sent while issue was closed.
This change broke all the arm builders in a confusing way.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b