{"record":{"id":"d84709c0e56c6ba3","repo":"2dust/v2rayN","slug":"failed-to-run-core-please-check-the-prompt-inform-d84709","errorCode":null,"errorMessage":"Failed to run Core, please check the prompt information","messagePattern":"Failed to run Core, please check the prompt information","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"v2rayN/ServiceLib/Manager/CoreManager.cs","lineNumber":358,"sourceCode":"        }\n\n        var procService = new ProcessService(\n            fileName: fileName,\n            arguments: string.Format(coreInfo.Arguments, coreInfo.AbsolutePath ? Utils.GetBinConfigPath(configPath).AppendQuotes() : configPath),\n            workingDirectory: Utils.GetBinConfigPath(),\n            displayLog: displayLog,\n            redirectInput: false,\n            environmentVars: environmentVars,\n            updateFunc: _updateFunc\n        );\n\n        await procService.StartAsync();\n\n        await Task.Delay(100);\n\n        if (procService is null or { HasExited: true })\n        {\n            throw new Exception(ResUI.FailedToRunCore);\n        }\n        AddProcessJob(procService.Handle);\n\n        return procService;\n    }\n\n    private void AddProcessJob(nint processHandle)\n    {\n        if (Utils.IsWindows())\n        {\n            _processJob ??= new();\n            try\n            {\n                _processJob?.AddProcess(processHandle);\n            }\n            catch { }\n        }\n    }","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/2dust/v2rayN/blob/e01717d8326a4f5060b335523590c5fda943fe03/v2rayN/ServiceLib/Manager/CoreManager.cs#L340-L376","documentation":"Thrown by the non-sudo core runner after StartAsync plus a 100ms wait when the process is null or already exited. Unlike the admin runner, this path starts the core directly (no sudo) and uses a fixed 100ms liveness probe, which can produce false failures on slow-starting cores.","triggerScenarios":"CoreManager builds a ProcessService with fileName/arguments/workingDirectory/environmentVars, calls StartAsync, awaits Task.Delay(100), then checks procService is null or HasExited. An exit within 100ms, or a core that has not yet signaled alive, trips the guard.","commonSituations":"Core binary crashed on a bad config (most common); missing executable permissions or wrong file path; missing shared libraries; the 100ms delay is too short for a slow machine so the process appears not-yet-ready; wrong arguments/env-var format string (coreInfo.Arguments/Environment format failure); architecture mismatch.","solutions":["Inspect the displayLog/updateFunc output for the core's startup error (bad config, missing lib, etc.).","Run the same core binary with the same arguments and working directory manually to reproduce.","Validate the generated config file and the coreInfo.Arguments format string.","Confirm the binary is executable and all dependencies resolve (ldd on Linux).","If the core legitimately needs >100ms to start, increase the liveness delay or poll HasExited instead of a single check."],"exampleFix":"// before - fixed 100ms probe, opaque error\nawait Task.Delay(100);\nif (procService is null or { HasExited: true })\n    throw new Exception(ResUI.FailedToRunCore);\n\n// after - poll briefly and include exit code/output\nusing var startCts = new CancellationTokenSource(TimeSpan.FromSeconds(3));\nwhile (!startCts.IsCancellationRequested)\n{\n    if (procService is null or { HasExited: true })\n        throw new Exception($\"{ResUI.FailedToRunCore} (exit={procService?.ExitCode}); see core log.\");\n    if (!procService.HasExited) break;\n    await Task.Delay(100, startCts.Token);\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight checks before starting the core\nif (!File.Exists(fileName)) throw new FileNotFoundException(\"Core binary not found\", fileName);\n// validate config path exists\nif (!File.Exists(configPath)) throw new FileNotFoundException(\"Config file not found\", configPath);","typeGuard":"static bool IsCoreExecutablePresent(string fileName) => File.Exists(fileName);","tryCatchPattern":"try\n{\n    var proc = await coreManager.RunCore();\n}\ncatch (Exception ex) when (ex.Message == ResUI.FailedToRunCore)\n{\n    // core exited within 100ms; almost always a bad config or missing dependency\n    _log?.Error(\"Core failed to start; check config and dependencies (ldd).\");\n}","preventionTips":["Inspect the core's displayLog output for the startup error.","Run the binary manually with the same arguments/working directory to reproduce.","Confirm executable bit and resolve all shared-library dependencies (ldd).","Validate the config file and the coreInfo.Arguments/Environment format strings.","If the core is slow to start, replace the fixed 100ms wait with a short poll."],"tags":["process","core","startup","cross-platform"],"backgroundTag":null,"analyzedSha":"e01717d8326a4f5060b335523590c5fda943fe03","analyzedAt":"2026-08-13T10:10:23.416Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}