Skip to content

Commit 07b8355

Browse files
authored
fn-dataplane: fix data race in extensions/config (#1460)
When passing call data to container task deep copy the maps to avoid race races. The call is not necessarily guaranteed to be scheduled on that container task and extensions/config map get modified while read.
1 parent 8191cc5 commit 07b8355

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

api/agent/agent.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,8 @@ func newHotContainer(ctx context.Context, evictor Evictor, call *call, cfg *Conf
12211221
return &container{
12221222
id: id, // XXX we could just let docker generate ids...
12231223
image: call.Image,
1224-
env: map[string]string(call.Config),
1225-
extensions: call.extensions,
1224+
env: cloneStrMap(call.Config), // avoid data race
1225+
extensions: cloneStrMap(call.extensions), // avoid date race
12261226
memory: call.Memory,
12271227
cpus: uint64(call.CPUs),
12281228
fsSize: cfg.MaxFsSize,
@@ -1405,3 +1405,11 @@ func (c *container) DockerAuth(ctx context.Context, image string) (*docker.AuthC
14051405
}
14061406
return nil, nil
14071407
}
1408+
1409+
func cloneStrMap(src map[string]string) map[string]string {
1410+
dst := make(map[string]string, len(src))
1411+
for k, v := range src {
1412+
dst[k] = v
1413+
}
1414+
return dst
1415+
}

0 commit comments

Comments
 (0)