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

Issue 13774043: code review 13774043: runtime: avoid allocation of internal panic values (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 7 months ago by rsc
Modified:
10 years, 7 months ago
Reviewers:
dvyukov
CC:
golang-dev, dvyukov, dfc
Visibility:
Public.

Description

runtime: avoid allocation of internal panic values If a fault happens in malloc, inevitably the next thing that happens is a deadlock trying to allocate the panic value that says the fault happened. Stop doing that, two ways. First, reject panic in malloc just as we reject panic in garbage collection. Second, runtime.panicstring was using an error implementation backed by a Go string, so the interface held an allocated *string. Since the actual errors are C strings, define a new error implementation backed by a C char*, which needs no indirection and therefore no allocation. This second fix will avoid allocation for errors like nil panic derefs or division by zero, so it is worth doing even though the first fix should take care of faults during malloc. Update issue 6419

Patch Set 1 #

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

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+36 lines, -1 line) Patch
M src/pkg/runtime/error.go View 1 1 chunk +16 lines, -0 lines 0 comments Download
M src/pkg/runtime/panic.c View 1 2 1 chunk +5 lines, -1 line 0 comments Download
M src/pkg/runtime/proc.c View 1 2 chunks +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/string.goc View 1 1 chunk +7 lines, -0 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
10 years, 7 months ago (2013-09-19 04:11:20 UTC) #1
dvyukov
LGTM
10 years, 7 months ago (2013-09-19 04:18:55 UTC) #2
dfc
On 2013/09/19 04:18:55, dvyukov wrote: > LGTM Thanks rsc. I hope that this will also ...
10 years, 7 months ago (2013-09-19 04:47:19 UTC) #3
rsc
10 years, 7 months ago (2013-09-20 19:15:33 UTC) #4
*** Submitted as https://code.google.com/p/go/source/detail?r=02f28778ccb9 ***

runtime: avoid allocation of internal panic values

If a fault happens in malloc, inevitably the next thing that happens
is a deadlock trying to allocate the panic value that says the fault
happened. Stop doing that, two ways.

First, reject panic in malloc just as we reject panic in garbage collection.

Second, runtime.panicstring was using an error implementation
backed by a Go string, so the interface held an allocated *string.
Since the actual errors are C strings, define a new error
implementation backed by a C char*, which needs no indirection
and therefore no allocation.

This second fix will avoid allocation for errors like nil panic derefs
or division by zero, so it is worth doing even though the first fix
should take care of faults during malloc.

Update issue 6419

R=golang-dev, dvyukov, dave
CC=golang-dev
https://codereview.appspot.com/13774043
Sign in to reply to this message.

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