Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4a524311
Commit
4a524311
authored
Feb 13, 2013
by
Dmitriy Vyukov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: instrument slicebytetostring for race detection
R=golang-dev, iant CC=golang-dev
https://golang.org/cl/7322068
parent
96082a69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
src/pkg/runtime/race/testdata/slice_test.go
src/pkg/runtime/race/testdata/slice_test.go
+20
-0
src/pkg/runtime/string.goc
src/pkg/runtime/string.goc
+12
-0
No files found.
src/pkg/runtime/race/testdata/slice_test.go
View file @
4a524311
...
...
@@ -443,3 +443,23 @@ func TestRaceSliceIndexAccess2(t *testing.T) {
_
=
s
[
v
]
<-
c
}
func
TestRaceSliceByteToString
(
t
*
testing
.
T
)
{
c
:=
make
(
chan
string
)
s
:=
make
([]
byte
,
10
)
go
func
()
{
c
<-
string
(
s
)
}()
s
[
0
]
=
42
<-
c
}
func
TestRaceSliceRuneToString
(
t
*
testing
.
T
)
{
c
:=
make
(
chan
string
)
s
:=
make
([]
rune
,
10
)
go
func
()
{
c
<-
string
(
s
)
}()
s
[
9
]
=
42
<-
c
}
src/pkg/runtime/string.goc
View file @
4a524311
...
...
@@ -6,6 +6,7 @@ package runtime
#
include
"runtime.h"
#
include
"arch_GOARCH.h"
#
include
"malloc.h"
#
include
"race.h"
String
runtime
·
emptystring
;
...
...
@@ -271,6 +272,12 @@ func intstring(v int64) (s String) {
}
func
slicebytetostring
(
b
Slice
)
(
s
String
)
{
void
*
pc
;
if
(
raceenabled
)
{
pc
=
runtime
·
getcallerpc
(&
b
);
runtime
·
racereadrangepc
(
b
.
array
,
b
.
len
,
1
,
pc
,
runtime
·
slicebytetostring
);
}
s
=
gostringsize
(
b
.
len
);
runtime
·
memmove
(
s
.
str
,
b
.
array
,
s
.
len
);
}
...
...
@@ -286,7 +293,12 @@ func slicerunetostring(b Slice) (s String) {
intgo
siz1
,
siz2
,
i
;
int32
*
a
;
byte
dum
[
8
];
void
*
pc
;
if
(
raceenabled
)
{
pc
=
runtime
·
getcallerpc
(&
b
);
runtime
·
racereadrangepc
(
b
.
array
,
b
.
len
*
sizeof
(*
a
),
sizeof
(*
a
),
pc
,
runtime
·
slicerunetostring
);
}
a
=
(
int32
*)
b
.
array
;
siz1
=
0
;
for
(
i
=
0
;
i
<
b
.
len
;
i
++)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment