Go bindings for libghostty-vt.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

terminal: fix checkptr failure under -race for cgo.Handle userdata

Converting a cgo.Handle (uintptr) directly to unsafe.Pointer in
NewTerminal triggered a checkptr "bad pointer value" panic when
running tests with -race. The handle is an opaque integer, not a
real Go pointer, so checkptr incorrectly rejects it.

Extract the conversion into a small handleToPointer helper
annotated with //go:nocheckptr to suppress the false positive.

+11 -1
+11 -1
terminal.go
··· 239 239 C.ghostty_terminal_set( 240 240 t.ptr, 241 241 C.GHOSTTY_TERMINAL_OPT_USERDATA, 242 - unsafe.Pointer(t.handle), 242 + handleToPointer(t.handle), 243 243 ) 244 244 245 245 // Register any effects that were provided via options. ··· 408 408 } 409 409 return &GridRef{ref: ref}, nil 410 410 } 411 + 412 + // handleToPointer converts a cgo.Handle (uintptr) to unsafe.Pointer 413 + // for passing as C userdata. The handle is an opaque integer, not a 414 + // real Go pointer, so we suppress checkptr which would otherwise 415 + // reject it under -race. 416 + // 417 + //go:nocheckptr 418 + func handleToPointer(h cgo.Handle) unsafe.Pointer { 419 + return unsafe.Pointer(h) 420 + }