-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: memory allocated by OS not in usable range (ARM) #13992
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
Comments
Fuller trace:
|
This can happen on a 32-bit system if your program is using too much memory--that is, if it is going to run out of memory anyhow. One thing to check is whether the program has a bug causing it to use memory without bounds. It is also possible that this is a Go runtime error. Does this error happen consistently? Is there a way that we can reproduce the problem? |
I'll try to create a repro of this issue. |
It says you are allocating a 256 MB slice. Is that true? On a 32-bit system, especially one co-existing with C code as in Android, there's just not that much address space to go around. The Android L runtime ART reserves its own virtual memory quite aggressively, so Go often can't get much more. What happened here is that Go asked for 256 MB for its heap bitmap (mostly that will never be mapped, it's just virtual address space), 2 MB for its span array, and some amount for its own memory. That amount is unclear: we try 512 MB, and if that fails then 256 MB, and if that fails then 128 MB. It's hard to say what finally worked here, but the kernel found the memory we wanted and gave it to us at 0x8123a000 or so, resulting in a heap base of 0x9143a000. Then when we asked for the 256 MB later, the OS gave us 0x60f2f000 (1626533888), which was below the heap base and therefore unusable to us. We need it to be in the 2 GB starting at the original arena base to be able to address it in our heap bitmap. The code that goes through this in runtime/malloc.go says:
The comment is somewhat out of date. In fact the code is reserving 256 MB of heap bitmap when it only needs to reserve 128 MB. We halved the footprint without updating the calculation of bitmapSize on that next-to-last line. It's too late for Go 1.6 but we could do one of two things in Go 1.7: (1) Halve the bitmapSize, since that's all we need for _MaxArena32 = 2GB. (2) Double _MaxArena32. That's what the "Alternatively ..." comment above is suggesting, but there the assumption is it will require 512 MB of bitmap. Now that bitmaps are half as big, we can keep using the same 256 MB we're already reserving and use it to describe the entire 4 GB space, letting us eliminate this class of crash entirely. I suspect we should do (2). But again it will need to wait for Go 1.7. |
/cc @RLH @aclements |
CL https://golang.org/cl/18975 mentions this issue. |
It's possible for arena_start+MaxArena32 to wrap. We do the right thing in the bounds check but not in the print. For #13992 (to fix the print there, not the bug). Change-Id: I4df845d0c03f0f35461b128e4f6765d3ccb71c6d Reviewed-on: https://go-review.googlesource.com/18975 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com>
We've found a bug in our code that used more memory than we anticipated it would, that may have caused running out of memory, and hitting some weird limits with the address space on 32 bit systems. If you wish you can close down this thread. I'll open a new one or post into this if the issue resurfaces. |
Thanks. Please reopen if the situation changes. |
@davecheney, are you sure? I think Russ' suggestions sounds good to me, eliminating this kind of crash entirely. |
It's the OP's choice, see above. |
I only said that we found a bug that increased the memory usage :P If there's a fix that would make the code more stable on 32 bit platforms I'm all for it :) |
CL https://golang.org/cl/20370 mentions this issue. |
Ok, my mistake. Reopening. |
CL https://golang.org/cl/20471 mentions this issue. |
I think the fix should be pushed to 1.6 branch. Building docker with go 1.6.2 fails on arm but works with 1.6.1. |
@ncopa, the fix for this issue is quite invasive and it's fixing something that has been a problem for many Go releases (that is, the problem wasn't introduced in Go 1.6; it certainly wasn't introduced in Go 1.6.2), so I'm afraid it isn't really a candidate for cherry-picking to 1.6. I'm surprised Docker built on ARM with 1.6.1 but not with 1.6.2. You could open a new issue about that with more details. |
@aclements yes. I should have opened a new issue. I tried to backport the fix but it didnt solve the it. Must be something else that is happening. |
Hey all,
I'm not sure whether this is a bug in Go, a bug in our code or something just odd, but thought I'd post it to get some pointers, as previous occurrences of this error usually meant bugs in the runtime.
One of our users were experimenting with running our Ethereum codebase on Android, ARMv7 with Go 1.6 beta1 or beta2 (didn't get a confirmation yet on it), and at a certain point he was hit with the non-usable memory error below:
Could this point to an underlying issue in Go, or should I look in our own code base? Given the oddity of the report that memory seems to be available but Go cannot use it, it seems to me that it's an issue with Go, but I'm not sure of it.
Update: I think the Android library producing this issue was built with 1.6beta1 (via xgo, notable this .aar bundle), will ask for a repro code if it's deemed to be a Go bug requiring investigation. The code was ran on a Sony Xperia Z2, which should have plenty of memory to cover the code's requirements.
Update 2: Given that the cross builds are from xgo, both ARMv7 and ARM64 libraries are included in there, so the issue might be with ARM64 and not ARMv7 as I originally thought.
The text was updated successfully, but these errors were encountered: