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

os: Index out of range on StartProcess call #11417

Closed
thomas-frantz opened this issue Jun 26, 2015 · 4 comments
Closed

os: Index out of range on StartProcess call #11417

thomas-frantz opened this issue Jun 26, 2015 · 4 comments
Milestone

Comments

@thomas-frantz
Copy link

@thomas-frantz thomas-frantz commented Jun 26, 2015

I'm running go 1.4.2 windows/amd64

I made a SO post here describing it: http://stackoverflow.com/questions/31072865/runtime-error-index-out-of-range-when-attempting-to-os-startprocess

Basically I'm attempting to start a process with os.StartProcess and a slice of arguments, but I keep getting an index out of range runtime error.

For simplicity, I also made this simplified go code to reproduce it for me:
http://play.golang.org/p/S6kRLMyd2I

which returns:

panic: runtime error: index out of range

goroutine 1 [running]:
syscall.StartProcess(0x4fa1f0, 0xe, 0xc082023f30, 0x1, 0x1, 0xc082023e20, 0x0, 0x0, 0x0, 0x0)
        c:/go/src/syscall/exec_windows.go:322 +0x94c
os.startProcess(0x4fa1f0, 0xe, 0xc082023f30, 0x1, 0x1, 0xc08200a280, 0x4db5e0, 0x0, 0x0)
        c:/go/src/os/exec_posix.go:45 +0x482
os.StartProcess(0x4fa1f0, 0xe, 0xc082023f30, 0x1, 0x1, 0xc08200a280, 0x4b5920, 0x0, 0x0)
        c:/go/src/os/doc.go:24 +0x79
main.main()
        C:/projects/go/gobug/gobug.go:11 +0xca

goroutine 2 [runnable]:
runtime.forcegchelper()
        c:/go/src/runtime/proc.go:90
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 3 [runnable]:
runtime.bgsweep()
        c:/go/src/runtime/mgc0.go:82
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 4 [runnable]:
runtime.runfinq()
        c:/go/src/runtime/malloc.go:712
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:2232 +0x1
exit status 2

@thomas-frantz

This comment has been minimized.

Copy link
Author

@thomas-frantz thomas-frantz commented Jun 26, 2015

Literally right as I hit post, a friend messaged me and said he fixed this lol. He's answering the SO post.

Edit: To help anyone else who might have this problem, my friend answered the SO post. On windows you apparently need to specify the stdin and stderr in the ProcAttr.

@ebfe

This comment has been minimized.

Copy link
Contributor

@ebfe ebfe commented Jun 26, 2015

There might actually be a bug. Looking at the code in syscall.StartProcess (src/syscall/exec_windows.go) it even handles the attr == nil case, but never verifies len(attr.Fd) > 2 before accessing fd[2] in line 322. cc @alexbrainman.

@mikioh mikioh changed the title Index out of range on os.StartProcess call os: Index out of range on StartProcess call Jun 27, 2015
@alexbrainman

This comment has been minimized.

Copy link
Member

@alexbrainman alexbrainman commented Jun 29, 2015

I agree, we should not panic. https://go-review.googlesource.com/11604

Alex

@alexbrainman alexbrainman reopened this Jun 29, 2015
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jun 29, 2015

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

@mikioh mikioh added this to the Go1.5 milestone Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.