router-for-me/CLIProxyAPI · error

allocate host api

Error message

allocate host api

What it means

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

Source

Thrown at internal/pluginhost/loader_unix.go:131

	defer C.free(unsafe.Pointer(cPath))

	handle := C.cliproxy_dlopen(cPath)
	if handle == nil {
		return nil, fmt.Errorf("dlopen %s: %s", file.Path, dlerrorString())
	}

	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)

View on GitHub (pinned to 78f0c4079e)

Solutions

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

When it happens

Trigger: Thrown at internal/pluginhost/loader_unix.go:131 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/52455b92412b92e4. Report an issue: GitHub.