Skip to content
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/debug: WriteHeapDump does not write a heapdump for go1.3beta2 windows #8119

Closed
gopherbot opened this issue May 29, 2014 · 7 comments
Closed
Milestone

Comments

@gopherbot
Copy link

by marcel.lanz:

What does 'go version' print?
go version go1.3beta2 windows/386

What steps reproduce the problem?

http://play.golang.org/p/jcL5Ab1ivY
build and run the programm.

What happened?
It produced a file named heapdump_win32 but of size 0 bytes

What should have happened instead?
it should write a heapdump to a file named heapdump_win32 with file size > 0 bytes

Please provide any additional information below:
Windows is Windows7, 64Bit
runtime/debug.WriteHeapDump works on OSX with: go version go1.3beta2 darwin/amd64

package main

import (
    "fmt"
    "os"
    "runtime/debug"
)

func main() {

    fmt.Println("writing heapdump")
    f, err := os.Create("heapdump_wind32")
    if err != nil {
        panic(err)
    }

    debug.WriteHeapDump(f.Fd())
    f.Close()
}

produces a file of 0 bytes on Windows and 137410 bytes on OSX
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4.

@ianlancetaylor
Copy link
Contributor

Comment 2:

Labels changed: added os-windows.

@randall77
Copy link
Contributor

Comment 3:

Owner changed to @randall77.

@randall77
Copy link
Contributor

Comment 4:

It looks like our windows write() implementation only handles stdout and stderr file
descriptors.  This is going to be nontrivial to fix.  Any windows experts out there know
how to write to a os.Create().Fd()?  Is it even possible?
os_windows.c:
int32
runtime·write(int32 fd, void *buf, int32 n)
{
    void *handle;
    uint32 written;
    written = 0;
    switch(fd) {
    case 1:
        handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-11);
        break;
    case 2:
        handle = runtime·stdcall(runtime·GetStdHandle, 1, (uintptr)-12);
        break;
    default:
        return -1;
    }
    runtime·stdcall(runtime·WriteFile, 5, handle, buf, (uintptr)n, &written, (uintptr)0);
    return written;
}

@minux
Copy link
Member

minux commented May 29, 2014

Comment 5:

I will fix this one. heapdump is introduced in this cycle, so i think we can
fix it before 1.3.

Labels changed: added release-go1.3maybe, removed release-go1.4.

@gopherbot
Copy link
Author

Comment 6:

CL https://golang.org/cl/93640044 mentions this issue.

@minux
Copy link
Member

minux commented May 31, 2014

Comment 7:

This issue was closed by revision a68b9be.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Fixes golang#8119.

LGTM=khr, rsc
R=alex.brainman, khr, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/93640044
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