]> Cypherpunks repositories - gostls13.git/commit
cmd/ld: clear unused ctxt before morestack
authorRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 18:53:08 +0000 (13:53 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 4 Mar 2014 18:53:08 +0000 (13:53 -0500)
commitc2dd33a46f66b2b56987ff9849f64513a4323385
tree2db01bc131ad58e629cb6c9687f0b5df7fb63203
parent542415c9df03e40a99ef9eb1005e43ba2cadc46a
cmd/ld: clear unused ctxt before morestack

For non-closure functions, the context register is uninitialized
on entry and will not be used, but morestack saves it and then the
garbage collector treats it as live. This can be a source of memory
leaks if the context register points at otherwise dead memory.
Avoid this by introducing a parallel set of morestack functions
that clear the context register, and use those for the non-closure functions.

I hope this will help with some of the finalizer flakiness, but it probably won't.

Fixes #7244.

LGTM=dvyukov
R=khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/71030044
15 files changed:
include/link.h
src/cmd/5g/gsubr.c
src/cmd/6g/gsubr.c
src/cmd/8g/gsubr.c
src/cmd/gc/closure.c
src/cmd/gc/go.h
src/cmd/gc/pgen.c
src/cmd/ld/textflag.h
src/liblink/obj5.c
src/liblink/obj6.c
src/liblink/obj8.c
src/pkg/runtime/asm_386.s
src/pkg/runtime/asm_amd64.s
src/pkg/runtime/asm_amd64p32.s
src/pkg/runtime/asm_arm.s