Documentation
¶
Overview ¶
Package uintptrcheck implements the `glutter-gen uintptrcheck` subcommand, which reads the Windows code and reports a Go pointer that is turned into a uintptr anywhere but in the argument list of a call that keeps it alive (SPEC §25.2).
A uintptr does not keep an object alive, and does not follow it when the stack moves. The compiler makes an exception for the arguments of a call to a function marked //go:uintptrescapes and for syscall.SyscallN: the object stays alive, on the heap, for the call. A conversion written earlier (into a variable, a table, a struct, or in an if that picks between a pointer and 0) has no such protection, and is wrong whenever the call runs Go code before it returns (a COM method of an object made in Go, a window procedure, a callback).
The check reads the syntax only, so it matches a callee by its name: the functions marked in the checked packages and the Syscall functions of the standard library.
Flutter: no counterpart.
Index ¶
Constants ¶
const RulePtrEscape = "ptr-escape"
RulePtrEscape says that uintptr(unsafe.Pointer(p)) is written in the argument list of a call to a function marked //go:uintptrescapes, or of syscall.SyscallN, and nowhere else.
Variables ¶
var DefaultDirs = []string{
"internal/platform/windows", "internal/gpu/d3d12", "internal/gpu/gdiwindow",
"internal/engine", "cmd/glutter-windows",
}
DefaultDirs are the directories that call Windows, below the root of the module.
Flutter: no counterpart.
Functions ¶
Types ¶
type Violation ¶
type Violation struct {
// Rule is RulePtrEscape.
Rule string
// File is the path of the file below the root, with slashes.
File string
// Func is the function that holds the code: "Name", "Type.Name", or "-" outside any.
Func string
// Line is where the conversion is.
Line int
// Message says what is wrong.
Message string
}
Violation is one place where a pointer is converted outside such an argument list.
Flutter: no counterpart.
func Check ¶
Check reads every .go file below the directories (whatever its build tags) and returns the violations, sorted by file and line.
Flutter: no counterpart.