proxypoke/i3ipc

Selecting the current workspace blows up

Opened this issue · 2 comments

I am currently on the current workspace, identified by the number 1, I am using the following script

package main

import "github.com/proxypoke/i3ipc"

func main() {
        i3ipc, err := i3ipc.GetIPCSocket()

        if err != nil {
                panic(err)
        }

        i3ipc.Command("workspace 1")
}

When I run it (to selected the currently selected workspace), it crashes with the following error:

$ go run i3_ipc.go
panic: runtime error: index out of range

goroutine 1 [running]:
runtime.panic(0x5296c0, 0x6b96b7)
    /usr/lib/google-golang/src/pkg/runtime/panic.c:266 +0xb6
github.com/proxypoke/i3ipc.(*IPCSocket).Command(0x4c210066f90, 0x560d90, 0xb, 0x4f0900, 0x0, ...)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/command.go:43 +0x1f4
main.main()
    /tmp/i3_ipc.go:12 +0x81

goroutine 4 [IO wait]:
net.runtime_pollWait(0x7f4002b8e248, 0x72, 0x0)
    /usr/lib/google-golang/src/pkg/runtime/netpoll.goc:116 +0x6a
net.(*pollDesc).Wait(0x4c2100501b0, 0x72, 0x7f4002b8d0c0, 0xb)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:81 +0x34
net.(*pollDesc).WaitRead(0x4c2100501b0, 0xb, 0x7f4002b8d0c0)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).Read(0x4c210050150, 0x4c21000a7c0, 0xe, 0xe, 0x0, ...)
    /usr/lib/google-golang/src/pkg/net/fd_unix.go:204 +0x2a0
net.(*conn).Read(0x4c210000100, 0x4c21000a7c0, 0xe, 0xe, 0xe, ...)
    /usr/lib/google-golang/src/pkg/net/net.go:122 +0xc5
github.com/proxypoke/i3ipc.(*IPCSocket).recv(0x4c210020360, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/socket.go:100 +0xc1
github.com/proxypoke/i3ipc.(*IPCSocket).listen(0x4c210020360)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:107 +0x41
created by github.com/proxypoke/i3ipc.init·1
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:155 +0x2c3

goroutine 6 [IO wait]:
net.runtime_pollWait(0x7f4002b8e1a0, 0x72, 0x0)
    /usr/lib/google-golang/src/pkg/runtime/netpoll.goc:116 +0x6a
net.(*pollDesc).Wait(0x4c210050450, 0x72, 0x7f4002b8d0c0, 0xb)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:81 +0x34
net.(*pollDesc).WaitRead(0x4c210050450, 0xb, 0x7f4002b8d0c0)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).Read(0x4c2100503f0, 0x4c21000a8b0, 0xe, 0xe, 0x0, ...)
    /usr/lib/google-golang/src/pkg/net/fd_unix.go:204 +0x2a0
net.(*conn).Read(0x4c2100001f8, 0x4c21000a8b0, 0xe, 0xe, 0xe, ...)
    /usr/lib/google-golang/src/pkg/net/net.go:122 +0xc5
github.com/proxypoke/i3ipc.(*IPCSocket).recv(0x4c210020d80, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/socket.go:100 +0xc1
github.com/proxypoke/i3ipc.(*IPCSocket).listen(0x4c210020d80)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:107 +0x41
created by github.com/proxypoke/i3ipc.init·1
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:155 +0x2c3

goroutine 7 [finalizer wait]:
runtime.park(0x40a350, 0x6bc6d0, 0x6bad88)
    /usr/lib/google-golang/src/pkg/runtime/proc.c:1342 +0x66
runfinq()
    /usr/lib/google-golang/src/pkg/runtime/mgc0.c:2312 +0x84
runtime.goexit()
    /usr/lib/google-golang/src/pkg/runtime/proc.c:1394

goroutine 9 [IO wait]:
net.runtime_pollWait(0x7f4002b8e0f8, 0x72, 0x0)
    /usr/lib/google-golang/src/pkg/runtime/netpoll.goc:116 +0x6a
net.(*pollDesc).Wait(0x4c2100507d0, 0x72, 0x7f4002b8d0c0, 0xb)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:81 +0x34
net.(*pollDesc).WaitRead(0x4c2100507d0, 0xb, 0x7f4002b8d0c0)
    /usr/lib/google-golang/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(*netFD).Read(0x4c210050770, 0x4c21000ad20, 0xe, 0xe, 0x0, ...)
    /usr/lib/google-golang/src/pkg/net/fd_unix.go:204 +0x2a0
net.(*conn).Read(0x4c2100002d8, 0x4c21000ad20, 0xe, 0xe, 0xe, ...)
    /usr/lib/google-golang/src/pkg/net/net.go:122 +0xc5
github.com/proxypoke/i3ipc.(*IPCSocket).recv(0x4c210066690, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/socket.go:100 +0xc1
github.com/proxypoke/i3ipc.(*IPCSocket).listen(0x4c210066690)
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:107 +0x41
created by github.com/proxypoke/i3ipc.init·1
    /usr/local/google/home/wmn/code/go/src/github.com/proxypoke/i3ipc/subscribe.go:155 +0x2c3
exit status 2

@eMxyzptlk: In case you are still interested in this you might want to give my primitive fix a shot.

koebi commented

This is not a bug in i3ipc, but in i3: i3/i3#2565
It looks like this is currently getting fixed, so no need to implement workaround here ;)