mirror of
https://github.com/golang/go
synced 2024-11-12 09:20:22 -07:00
runtime: Fix race detector checks to ignore KindNoPointers bit
when comparing kinds. R=dvyukov, dave, khr CC=golang-codereviews https://golang.org/cl/41660045
This commit is contained in:
parent
13141315ad
commit
f59ea4e58b
@ -998,10 +998,7 @@ runtime·mapaccess1(MapType *t, Hmap *h, byte *ak, byte *av)
|
|||||||
{
|
{
|
||||||
if(raceenabled && h != nil) {
|
if(raceenabled && h != nil) {
|
||||||
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess1);
|
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess1);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(ak, t->key, runtime·getcallerpc(&t), runtime·mapaccess1);
|
||||||
runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapaccess1);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess1);
|
|
||||||
}
|
}
|
||||||
if(h == nil || h->count == 0) {
|
if(h == nil || h->count == 0) {
|
||||||
av = t->elem->zero;
|
av = t->elem->zero;
|
||||||
@ -1032,10 +1029,7 @@ runtime·mapaccess2(MapType *t, Hmap *h, byte *ak, byte *av, bool pres)
|
|||||||
{
|
{
|
||||||
if(raceenabled && h != nil) {
|
if(raceenabled && h != nil) {
|
||||||
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess2);
|
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess2);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(ak, t->key, runtime·getcallerpc(&t), runtime·mapaccess2);
|
||||||
runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapaccess2);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(h == nil || h->count == 0) {
|
if(h == nil || h->count == 0) {
|
||||||
@ -1073,10 +1067,7 @@ reflect·mapaccess(MapType *t, Hmap *h, byte *key, byte *val)
|
|||||||
{
|
{
|
||||||
if(raceenabled && h != nil) {
|
if(raceenabled && h != nil) {
|
||||||
runtime·racereadpc(h, runtime·getcallerpc(&t), reflect·mapaccess);
|
runtime·racereadpc(h, runtime·getcallerpc(&t), reflect·mapaccess);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(key, t->key, runtime·getcallerpc(&t), reflect·mapaccess);
|
||||||
runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapaccess);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapaccess);
|
|
||||||
}
|
}
|
||||||
val = hash_lookup(t, h, &key);
|
val = hash_lookup(t, h, &key);
|
||||||
FLUSH(&val);
|
FLUSH(&val);
|
||||||
@ -1092,14 +1083,8 @@ runtime·mapassign1(MapType *t, Hmap *h, byte *ak, byte *av)
|
|||||||
|
|
||||||
if(raceenabled) {
|
if(raceenabled) {
|
||||||
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapassign1);
|
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapassign1);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(ak, t->key, runtime·getcallerpc(&t), runtime·mapassign1);
|
||||||
runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapassign1);
|
runtime·racereadobjectpc(av, t->elem, runtime·getcallerpc(&t), runtime·mapassign1);
|
||||||
else
|
|
||||||
runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapassign1);
|
|
||||||
if(t->elem->kind == KindArray || t->elem->kind == KindStruct)
|
|
||||||
runtime·racereadrangepc(av, t->elem->size, runtime·getcallerpc(&t), runtime·mapassign1);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(av, runtime·getcallerpc(&t), runtime·mapassign1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_insert(t, h, ak, av);
|
hash_insert(t, h, ak, av);
|
||||||
@ -1125,10 +1110,7 @@ runtime·mapdelete(MapType *t, Hmap *h, byte *ak)
|
|||||||
|
|
||||||
if(raceenabled) {
|
if(raceenabled) {
|
||||||
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapdelete);
|
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapdelete);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(ak, t->key, runtime·getcallerpc(&t), runtime·mapdelete);
|
||||||
runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapdelete);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapdelete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_remove(t, h, ak);
|
hash_remove(t, h, ak);
|
||||||
@ -1151,14 +1133,8 @@ reflect·mapassign(MapType *t, Hmap *h, byte *key, byte *val)
|
|||||||
runtime·panicstring("assignment to entry in nil map");
|
runtime·panicstring("assignment to entry in nil map");
|
||||||
if(raceenabled) {
|
if(raceenabled) {
|
||||||
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapassign);
|
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapassign);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(key, t->key, runtime·getcallerpc(&t), reflect·mapassign);
|
||||||
runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapassign);
|
runtime·racereadobjectpc(val, t->elem, runtime·getcallerpc(&t), reflect·mapassign);
|
||||||
else
|
|
||||||
runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapassign);
|
|
||||||
if(t->elem->kind == KindArray || t->elem->kind == KindStruct)
|
|
||||||
runtime·racereadrangepc(val, t->elem->size, runtime·getcallerpc(&t), reflect·mapassign);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(val, runtime·getcallerpc(&t), reflect·mapassign);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_insert(t, h, key, val);
|
hash_insert(t, h, key, val);
|
||||||
@ -1183,10 +1159,7 @@ reflect·mapdelete(MapType *t, Hmap *h, byte *key)
|
|||||||
runtime·panicstring("delete from nil map");
|
runtime·panicstring("delete from nil map");
|
||||||
if(raceenabled) {
|
if(raceenabled) {
|
||||||
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapdelete);
|
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapdelete);
|
||||||
if(t->key->kind == KindArray || t->key->kind == KindStruct)
|
runtime·racereadobjectpc(key, t->key, runtime·getcallerpc(&t), reflect·mapdelete);
|
||||||
runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapdelete);
|
|
||||||
else
|
|
||||||
runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapdelete);
|
|
||||||
}
|
}
|
||||||
hash_remove(t, h, key);
|
hash_remove(t, h, key);
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "arch_GOARCH.h"
|
#include "arch_GOARCH.h"
|
||||||
#include "malloc.h"
|
#include "malloc.h"
|
||||||
#include "race.h"
|
#include "race.h"
|
||||||
|
#include "type.h"
|
||||||
|
#include "typekind.h"
|
||||||
#include "../../cmd/ld/textflag.h"
|
#include "../../cmd/ld/textflag.h"
|
||||||
|
|
||||||
void runtime∕race·Initialize(uintptr *racectx);
|
void runtime∕race·Initialize(uintptr *racectx);
|
||||||
@ -280,6 +282,30 @@ runtime·racereadrangepc(void *addr, uintptr sz, void *callpc, void *pc)
|
|||||||
rangeaccess(addr, sz, (uintptr)callpc, (uintptr)pc, false);
|
rangeaccess(addr, sz, (uintptr)callpc, (uintptr)pc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime·racewriteobjectpc(void *addr, Type *t, void *callpc, void *pc)
|
||||||
|
{
|
||||||
|
uint8 kind;
|
||||||
|
|
||||||
|
kind = t->kind & ~KindNoPointers;
|
||||||
|
if(kind == KindArray || kind == KindStruct)
|
||||||
|
rangeaccess(addr, t->size, (uintptr)callpc, (uintptr)pc, true);
|
||||||
|
else
|
||||||
|
memoryaccess(addr, (uintptr)callpc, (uintptr)pc, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime·racereadobjectpc(void *addr, Type *t, void *callpc, void *pc)
|
||||||
|
{
|
||||||
|
uint8 kind;
|
||||||
|
|
||||||
|
kind = t->kind & ~KindNoPointers;
|
||||||
|
if(kind == KindArray || kind == KindStruct)
|
||||||
|
rangeaccess(addr, t->size, (uintptr)callpc, (uintptr)pc, false);
|
||||||
|
else
|
||||||
|
memoryaccess(addr, (uintptr)callpc, (uintptr)pc, false);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·raceacquire(void *addr)
|
runtime·raceacquire(void *addr)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,8 @@ void runtime·racewritepc(void *addr, void *callpc, void *pc);
|
|||||||
void runtime·racereadpc(void *addr, void *callpc, void *pc);
|
void runtime·racereadpc(void *addr, void *callpc, void *pc);
|
||||||
void runtime·racewriterangepc(void *addr, uintptr sz, void *callpc, void *pc);
|
void runtime·racewriterangepc(void *addr, uintptr sz, void *callpc, void *pc);
|
||||||
void runtime·racereadrangepc(void *addr, uintptr sz, void *callpc, void *pc);
|
void runtime·racereadrangepc(void *addr, uintptr sz, void *callpc, void *pc);
|
||||||
|
void runtime·racereadobjectpc(void *addr, Type *t, void *callpc, void *pc);
|
||||||
|
void runtime·racewriteobjectpc(void *addr, Type *t, void *callpc, void *pc);
|
||||||
void runtime·racefingo(void);
|
void runtime·racefingo(void);
|
||||||
void runtime·raceacquire(void *addr);
|
void runtime·raceacquire(void *addr);
|
||||||
void runtime·raceacquireg(G *gp, void *addr);
|
void runtime·raceacquireg(G *gp, void *addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user