BurntSushi / xgb

The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.
Other
489 stars 75 forks source link

Create-window example not working #21

Closed aarzilli closed 10 years ago

aarzilli commented 10 years ago

When executing go run examples/create-window/main.go I get this errors: Checked Error for mapping window 31457281: BadWindow {NiceName: Window, Sequence: 3, BadValue: 31457281, MinorOpcode: 0, MajorOpcode: 8} Checked Error for mapping window 0x1: BadWindow {NiceName: Window, Sequence: 5, BadValue: 0, MinorOpcode: 0, MajorOpcode: 8} Error: BadWindow {NiceName: Window, Sequence: 1, BadValue: 8781824, MinorOpcode: 0, MajorOpcode: 1} Error: BadWindow {NiceName: Window, Sequence: 2, BadValue: 31457281, MinorOpcode: 0, MajorOpcode: 2} No windows appear and the program waits until I sigterm it. I ran a git-bisect on this and the problem appears revision c3541209a0fb8271645c882f7e4a4d7254823992 (the one about the Str type padding).

I'm running Fedora 19, go version 1.2.

peterh commented 10 years ago

I just hit the same problem, except in the connection block (because my server's vendor string is not a multiple of four bytes long): panic: runtime error: index out of range

goroutine 1 [running]:
runtime.panic(0x5547e0, 0x740f17)
        /home/peterh/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/BurntSushi/xgb/xproto.VisualInfoRead(0xc210039269, 0x3, 0x3, 0xc210078078, 0x18)
        /home/peterh/src/github.com/BurntSushi/xgb/xproto/xproto.go:6291 +0x3bd
github.com/BurntSushi/xgb/xproto.VisualInfoReadList(0xc2100391d9, 0x93, 0x93, 0xc210078000, 0x107, ...)
        /home/peterh/src/github.com/BurntSushi/xgb/xproto/xproto.go:6322 +0xe9
github.com/BurntSushi/xgb/xproto.DepthInfoRead(0xc2100391d1, 0x9b, 0x9b, 0xc21004f180, 0xc200000001)

(etc)

The size calculation is inconsistent. c354120 removed padding from SetupInfoRead function, but not from (v SetupInfo) Bytes(). They're both wrong (in general; Bytes() is correct in this particular instance), because the root of the problem is the padding decision. xcb currently follows C rules: padding should be inserted after a string iff the next field needs to be aligned. It's not a decision that can be made while looking at a single field.

Personally, I've never liked implicit padding. Long term, I'm happier with adding <pad align="4" /> to xcb/proto to explicitly mark where padding should be inserted.

BurntSushi commented 10 years ago

Closed by #22.