wailsapp/wails · error

GlobalLock failed

Error message

GlobalLock failed

What it means

Error "GlobalLock failed" thrown in wailsapp/wails.

Source

Thrown at v3/pkg/w32/kernel32.go:143

		panic("GlobalAlloc failed")
	}

	return HGLOBAL(ret)
}

func GlobalFree(hMem HGLOBAL) {
	ret, _, _ := procGlobalFree.Call(uintptr(hMem))

	if ret != 0 {
		panic("GlobalFree failed")
	}
}

func GlobalLock(hMem HGLOBAL) unsafe.Pointer {
	ret, _, _ := procGlobalLock.Call(uintptr(hMem))

	if ret == 0 {
		panic("GlobalLock failed")
	}

	return unsafe.Pointer(ret)
}

func GlobalUnlock(hMem HGLOBAL) bool {
	ret, _, _ := procGlobalUnlock.Call(uintptr(hMem))

	return ret != 0
}

func MoveMemory(destination, source unsafe.Pointer, length uint32) {
	procMoveMemory.Call(
		uintptr(unsafe.Pointer(destination)),
		uintptr(source),
		uintptr(length))
}

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Ensure the HGLOBAL passed to GlobalLock is a valid handle allocated with GlobalAlloc using GMEM_MOVEABLE.
  2. Do not lock a handle that has already been freed or discarded; check the handle before locking.
  3. Check for system memory exhaustion, which can also make GlobalLock fail.

When it happens

Trigger: Occurs when GlobalLock returns NULL, e.g. the global memory handle is invalid, discarded, or the memory object has been freed.

Common situations: See trigger scenarios.


AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15). Data as JSON: /api/errors/c9c2e4f12219a9d8. Report an issue: GitHub.