Skip to content

runtime: out-of-memory error is inscrutable #594

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

Closed
rogpeppe opened this issue Feb 9, 2010 · 10 comments
Closed

runtime: out-of-memory error is inscrutable #594

rogpeppe opened this issue Feb 9, 2010 · 10 comments
Milestone

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Feb 9, 2010

on my machine, running the code below gives rise to the
following error message:

SIGBUS: bus error
Faulting address: 0xf1
pc: 0x7af3

throw: malloc/free - deadlock
double panic

this is not an ideal message when the real problem is
probably that it cannot allocate that much memory
(mine fails at 1GB)

package main
import "fmt"
func main() {
    var buf = make([]byte, 1)
    for {
        buf = make([]byte, len(buf) * 2)
    }
}

darwin 386
b45e8d6389ae tip
@rsc
Copy link
Contributor

rsc commented Feb 12, 2010

Comment 1:

Labels changed: added packagechange.

Status changed to Accepted.

@gopherbot
Copy link
Contributor

Comment 2 by giles.lean:

I'd like to see a further enhancement to make(): I'd like it to report failure other
than with a runtime error.  This needn't break backward compatibility other than very
minorly, e.g.:
var buf []byte
var ok os.Error
buf, ok = make([]byte, ...) // return with ok != nil on failure
buf = make([]byte, ...)     // runtime error as currently implemented
Providing the make() is presumed to provide two values any time it is used in tuple
assignment, existing code like the following would at least get an "assignment count
mismatch" compile time error:
var buf []byte
var s string
buf, s = make([]byte, ...), "fubar"
file.go: assignment count mismatch: 3 = 2
Or maybe it's not too late an incompatible change; the language still seems at least
somewhat in flux.

@rsc
Copy link
Contributor

rsc commented Feb 23, 2010

Comment 3:

Issue #620 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2011

Comment 4:

Labels changed: added priority-later.

@rsc
Copy link
Contributor

rsc commented Dec 12, 2011

Comment 5:

Labels changed: added priority-go1.

@robpike
Copy link
Contributor

robpike commented Jan 13, 2012

Comment 6:

Owner changed to builder@golang.org.

@rsc
Copy link
Contributor

rsc commented Jan 24, 2012

Comment 7:

This is probably only true on 32-bit.
On 64-bit I get a nice
panic: runtime error: makeslice: len out of range

@rsc
Copy link
Contributor

rsc commented Jan 30, 2012

Comment 8:

Labels changed: added go1-must.

@ality
Copy link
Member

ality commented Feb 3, 2012

Comment 9:

The error message on looks fine to me (on linux-386, at least):
runtime: memory allocated by OS not in usable range
runtime: out of memory: cannot allocate 268435456-byte block (269484032 in use)
throw: out of memory
goroutine 1 [running]:
main.main()
    /tmp/foo.go:6 +0x7d

@rsc
Copy link
Contributor

rsc commented Feb 6, 2012

Comment 10:

It used to be worse (as in the initial report); I think this is fixed now.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants