FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
cmd/gc: instrument blocks for race detection.

It happens that blocks are used for function calls in a
quite low-level way so they cannot be instrumented as
usual.

Blocks are also used for inlined functions.

Please review this at http://codereview.appspot.com/6821068/

Affected files:
M src/cmd/gc/racewalk.c


Index: src/cmd/gc/racewalk.c
===================================================================
--- a/src/cmd/gc/racewalk.c
+++ b/src/cmd/gc/racewalk.c
@@ -88,6 +88,7 @@
racewalknode(Node **np, NodeList **init, int wr, int skip)
{
Node *n, *n1;
+ NodeList *fini;

n = *np;

@@ -116,8 +117,29 @@
goto ret;

case OBLOCK:
- // leads to crashes.
- //racewalklist(n->list, nil);
+ if(n->list == nil)
+ goto ret;
+
+ switch(n->list->n->op) {
+ case OCALLFUNC:
+ case OCALLMETH:
+ case OCALLINTER:
+ // Blocks are used for multiple return function calls.
+ // x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]}
+ // We don't want to instrument between the statements because it will
+ // smash the results.
+ racewalknode(&n->list->n, &n->ninit, 0, 0);
+ fini = nil;
+ racewalklist(n->list->next, &fini);
+ n->list = concat(n->list, fini);
+ break;
+
+ default:
+ // Ordinary block, for loop initialization or inlined bodies.
+ racewalklist(n->ninit, nil);
+ racewalklist(n->list, nil);
+ break;
+ }
goto ret;

case ODEFER:

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 1, '12 at 8:07p
activeNov 2, '12 at 11:11p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase