Skip to content

os/exec: "fork/exec ... cannot allocate memory" on linux,!amd64 #31936

Closed
@4a6f656c

Description

@4a6f656c

What version of Go are you using (go version)?

$ go version
go version devel +5286b2a Thu May 9 14:58:03 2019 +0000 linux/s390x

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

linux/s390x

What did you do?

On a linux/s390x LPAR with 12GB of RAM:

package main

import (
        "log"
        "os/exec"
)

func main() {
        c := 8 * 1024 * 1024 * 1024
        a := make([]byte, c, c)
        for i := range a {
                a[i] = byte(i % 255)
        }

        log.Print(exec.Command("sleep", "1").Run())
}
$ go build -o fork fork.go

What did you expect to see?

$ ./fork
2019/05/07 04:21:46 <nil>

What did you see instead?

$ ./fork
2019/05/07 03:59:54 fork/exec /bin/sleep: cannot allocate memory

This causes a production impact since various Go programs cannot fork/exec (including the Go compiler at times).

This is reproducable under Linux on most architectures aside from linux/amd64, where the problem has been addressed via issue #5838. The memory consumption will need to be altered depending on the available host memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions