router-for-me/CLIProxyAPI · error

allocate host context

Error message

allocate host context

What it means

Error "allocate host context" thrown in router-for-me/CLIProxyAPI.

Source

Thrown at internal/pluginhost/loader_unix.go:137

	cSymbol := C.CString("cliproxy_plugin_init")
	initSymbol := C.cliproxy_dlsym(handle, cSymbol)
	C.free(unsafe.Pointer(cSymbol))
	if initSymbol == nil {
		C.cliproxy_dlclose(handle)
		return nil, fmt.Errorf("missing cliproxy_plugin_init: %s", dlerrorString())
	}

	hostAPI := (*C.cliproxy_host_api)(C.malloc(C.size_t(unsafe.Sizeof(C.cliproxy_host_api{}))))
	if hostAPI == nil {
		C.cliproxy_dlclose(handle)
		return nil, fmt.Errorf("allocate host api")
	}
	hostCtx := C.malloc(C.size_t(unsafe.Sizeof(C.uintptr_t(0))))
	if hostCtx == nil {
		C.free(unsafe.Pointer(hostAPI))
		C.cliproxy_dlclose(handle)
		return nil, fmt.Errorf("allocate host context")
	}
	id := hostCallbackID.Add(1)
	*(*C.uintptr_t)(hostCtx) = C.uintptr_t(id)
	hostCallbackEntries.Store(id, dynamicHostCallbackEntry{host: host, pluginID: file.ID})
	C.cliproxy_set_host_api(hostAPI, C.uint32_t(pluginHostABIVersion), hostCtx)

	client := &dynamicLibraryClient{
		handle:  handle,
		hostAPI: hostAPI,
		hostCtx: hostCtx,
	}
	rc := C.cliproxy_call_init(initSymbol, hostAPI, &client.api)
	if rc != 0 {
		client.Shutdown()
		return nil, fmt.Errorf("cliproxy_plugin_init returned %d", int(rc))
	}
	if uint32(client.api.abi_version) != pluginHostABIVersion {
		client.Shutdown()

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Check host memory availability; the host context allocation failed.
  2. Restart the server if the allocation failure persists.

When it happens

Trigger: Thrown at internal/pluginhost/loader_unix.go:137 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/1a4efccab3e7d9de. Report an issue: GitHub.