-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime/pprof: tests "out of memory" on Plan 9 #9712
Comments
I need help figuring out why happens. David, can you log all calls to sysAlloc, total memory consumption and errno value? |
The issue doesn't seem to be related to runtime/pprof specifically.
For example: TestTraceDoubleStart fails when executed after TestTraceStartStop:
TestTraceDoubleStart succeed when ran individually:
TestTrace always fails:
|
There is at least one buf in mem_plan9.go that can lead to memory corruption (the same memory returned by sysAlloc twice). The following line in sysFree: But even if you replace it with I would do the following. It has much simpler invariants: both bloc and n are always page-rounded: --- a/src/runtime/mem_plan9.go
+++ b/src/runtime/mem_plan9.go
@@ -9,21 +9,24 @@ import "unsafe"
var bloc uintptr
var memlock mutex
-const memRound = _PAGESIZE - 1
+func memRound(p uintptr) uintptr {
+ return (p + _PAGESIZE - 1) &^ (_PAGESIZE - 1)
+}
func initBloc() {
- bloc = uintptr(unsafe.Pointer(&end))
+ bloc = memRound(uintptr(unsafe.Pointer(&end)))
}
func sbrk(n uintptr) unsafe.Pointer {
lock(&memlock)
// Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c
- bl := (bloc + memRound) &^ memRound
+ bl := bloc
+ n = memRound(n)
if brk_(unsafe.Pointer(bl+n)) < 0 {
unlock(&memlock)
return nil
}
- bloc = bl + n
+ bloc += n
unlock(&memlock)
return unsafe.Pointer(bl)
}
@@ -42,7 +45,7 @@ func sysFree(v unsafe.Pointer, n uintptr, stat *uint64) {
// from tiny/mem.c
// Push pointer back if this is a free
// of the most recent sysAlloc.
- n += (n + memRound) &^ memRound
+ n = memRound(n)
if bloc == uintptr(v)+n {
bloc -= n
} I see that in your scenario the corruption thing actually happens: sysAlloc (65536, 0x275f80) sysAlloc (65536, 0x275f80) sysFree (0x30493000, 65536, 0x275f80) The first sysFree(0x30493000) will move bloc to 0x30493000 even if it is not the last allocated block. However, this does not seem to explain why brk fails. |
Thanks. Your fix seems to fix the corruption issue After your fix, all the tests passes successfully.
I think brk can be used for shrinking as well. |
The runtime/pprof trace_parser_test.go and trace_test.go
test files were added in CL 2039.
TestTraceDoubleStart, TestTrace, TestTraceStres and
TestTraceSymbolize are failing on Plan 9 ("out of memory").
However, only TestTrace is failing when the tests are run individually.
The text was updated successfully, but these errors were encountered: