Skip to content

v3.3: glfw.GetKeyName() crashes on unknown key+scancode on Wayland #413

@vs49688

Description

@vs49688

As in title.

On my Linux/Wayland machine (NixOS + Apple Silicon), pressing the fn key triggers a panic (scancode 464).
It does not happen on X11.

I hit this first in Supersonic, and found #386, but that's on MacOS.

This is reproducible on current master (da16c12 at time of writing), using glfw 3.3.10.

Reproducer:

package main

import (
	"fmt"
	"runtime"

	"github.com/go-gl/glfw/v3.3/glfw"
)

func init() {
	runtime.LockOSThread()
}

func main() {
	err := glfw.Init()
	if err != nil {
		panic(err)
	}
	defer glfw.Terminate()

	fmt.Printf("GLFW Version: %s\n", glfw.GetVersionString())

	name := glfw.GetKeyName(glfw.KeyUnknown, 464)
	fmt.Println(name)

}

Output:

$ go run -tags wayland ./main.go 
# github.com/go-gl/glfw/v3.3/glfw
In file included from vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw_lin.go:9:
vendor/github.com/go-gl/glfw/v3.3/glfw/glfw/src/wl_window.c:29:9: warning: ‘_GNU_SOURCE’ redefined
   29 | #define _GNU_SOURCE
      |         ^~~~~~~~~~~
<command-line>: note: this is the location of the previous definition
GLFW Version: 3.3.10 Wayland EGL OSMesa clock_gettime evdev
panic: InvalidValue: Wayland: Invalid scancode 464

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError({0x0, 0x0, 0x40000c01a0?})
        /home/zane/Documents/Coding/glfwcrashtest/vendor/github.com/go-gl/glfw/v3.3/glfw/error.go:177 +0x158
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
        /home/zane/Documents/Coding/glfwcrashtest/vendor/github.com/go-gl/glfw/v3.3/glfw/error.go:188
github.com/go-gl/glfw/v3.3/glfw.GetKeyName(0x5097d8?, 0x400007e020?)
        /home/zane/Documents/Coding/glfwcrashtest/vendor/github.com/go-gl/glfw/v3.3/glfw/input.go:445 +0x3c
main.main()
        /home/zane/Documents/Coding/glfwcrashtest/main.go:23 +0x8c
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions