{"record":{"id":"6dde59a897a8042d","repo":"XTLS/Xray-core","slug":"cannot-start-all-fake-dns-pools","errorCode":null,"errorMessage":"Cannot start all fake dns pools","messagePattern":"Cannot start all fake dns pools","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/dns/fakedns/fake.go","lineNumber":192,"sourceCode":"\nfunc (h *HolderMulti) GetDomainFromFakeDNS(ip net.Address) string {\n\tfor _, v := range h.holders {\n\t\tif domain := v.GetDomainFromFakeDNS(ip); domain != \"\" {\n\t\t\treturn domain\n\t\t}\n\t}\n\treturn \"\"\n}\n\nfunc (h *HolderMulti) Type() interface{} {\n\treturn (*dns.FakeDNSEngine)(nil)\n}\n\nfunc (h *HolderMulti) Start() error {\n\tfor _, v := range h.holders {\n\t\tif v.config != nil && v.config.IpPool != \"\" && v.config.LruSize != 0 {\n\t\t\tif err := v.Start(); err != nil {\n\t\t\t\treturn errors.New(\"Cannot start all fake dns pools\").Base(err)\n\t\t\t}\n\t\t} else {\n\t\t\treturn errors.New(\"invalid fakeDNS setting\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (h *HolderMulti) Close() error {\n\tvar errs []error\n\tfor _, v := range h.holders {\n\t\terrs = append(errs, v.Close())\n\t}\n\treturn errors.Combine(errs...)\n}\n\nfunc (h *HolderMulti) createHolderGroups() error {\n\tfor _, v := range h.config.Pools {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/app/dns/fakedns/fake.go#L174-L210","documentation":"After writing all chunks, writePaddingTurnWithBuffer verifies that chunk lengths sum exactly to recordLength. defaultPaddingChunks and prefix-trimmed variants satisfy this by construction, so a mismatch indicates an internal arithmetic bug (e.g. a fork altering chunk generation or trimming) rather than a runtime condition. The turn has already been fully written to the wire when this fires.","triggerScenarios":"Modified trimPaddingPrefix/defaultPaddingChunks logic that drops or adds bytes; a variant whose delays length differs from chunks does not cause this (delays are orthogonal), but any change that mutates chunk lengths after computation can.","commonSituations":"Local patches to the chunk-splitting or prefix-trimming helpers; none in unmodified code.","solutions":["Diff local changes against upstream for defaultPaddingChunks, trimPaddingPrefix, and the chunk loop","Add a unit test asserting sum(chunks) == targetLength - prefixLength for all schedule fixtures","Revert experimental chunking changes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func chunksSumToRecord(chunks []int, target, prefix int) bool {\n    sum := 0\n    for _, c := range chunks {\n        sum += c\n    }\n    return sum == target-prefix\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"padding chunks total\") {\n    // internal invariant break: connection already emitted wrong bytes; drop it and report a bug\n}","preventionTips":["Unit-test that generated chunks sum to recordLength for all fixtures","Never mutate chunk slices after they are computed"],"tags":["padding","invariant","defensive","xmc"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}