{"record":{"id":"cf44ececde541ad6","repo":"golang/go","slug":"scanning-s-v","errorCode":null,"errorMessage":"scanning %s: %v","messagePattern":"scanning (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/ssagen/ssa.go","lineNumber":978,"sourceCode":"}\n\nfunc readFuncLines(file string, start, end uint) (*ssa.FuncLines, error) {\n\tf, err := os.Open(os.ExpandEnv(file))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close() // ignore error\n\tvar lines []string\n\tln := uint(1)\n\tscanner := bufio.NewScanner(f)\n\tfor scanner.Scan() && ln <= end {\n\t\tif ln >= start {\n\t\t\tlines = append(lines, scanner.Text())\n\t\t}\n\t\tln++\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"scanning %s: %v\", file, err)\n\t}\n\treturn &ssa.FuncLines{Filename: file, StartLineno: start, Lines: lines}, nil\n}\n\n// updateUnsetPredPos propagates the earliest-value position information for b\n// towards all of b's predecessors that need a position, and recurs on that\n// predecessor if its position is updated. B should have a non-empty position.\nfunc (s *state) updateUnsetPredPos(b *ssa.Block) {\n\tif b.Pos == src.NoXPos {\n\t\ts.Fatalf(\"Block %s should have a position\", b)\n\t}\n\tbestPos := src.NoXPos\n\tfor _, e := range b.Preds {\n\t\tp := e.Block()\n\t\tif !p.LackingPos() {\n\t\t\tcontinue\n\t\t}\n\t\tif bestPos == src.NoXPos {","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/ssagen/ssa.go#L960-L996","documentation":"The SSA backend reads source files via readFuncLines to obtain line-by-line content for debug position information. It uses bufio.Scanner which has a default maximum token (line) size of 64*1024 bytes. This error wraps any scanner.Err() failure, most commonly bufio.ErrTooLong when a single line exceeds the buffer limit.","triggerScenarios":"A Go source file containing a single line longer than 64KB (the bufio.Scanner default buffer size). Machine-generated Go files with enormous string literals, base64 blobs, or embedded data on a single line. Files with missing newlines.","commonSituations":"Code generators that emit very long lines (e.g., stringified JSON, base64-encoded images). go:generate tools that produce single-line output. Minified or machine-written Go files. Files with very long //go:embed or import lists.","solutions":["Split very long lines into multiple shorter lines in the source file","Configure your code generator to produce output with reasonable line lengths","Move large embedded data to separate files and use //go:embed instead of inline string literals","If generating Go code, insert newlines after each statement or struct field"],"exampleFix":"// before (single line)\nvar data = \"<base64 string that is 100KB long>\"\n\n// after (split across lines)\nvar data = \"<chunk1>\" +\n    \"<chunk2>\" +\n    \"<chunk3>\"","handlingStrategy":"validation","validationCode":"// Check for excessively long lines in Go source files\nimport (\n    \"bufio\"\n    \"os\"\n)\n\nfunc checkLongLines(path string, maxLineLen int) error {\n    f, err := os.Open(path)\n    if err != nil {\n        return err\n    }\n    defer f.Close()\n    scanner := bufio.NewScanner(f)\n    scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024) // allow up to 1MB lines for scanning\n    lineNum := 0\n    for scanner.Scan() {\n        lineNum++\n        if len(scanner.Bytes()) > maxLineLen {\n            return fmt.Errorf(\"%s:%d: line length %d exceeds %d bytes\", path, lineNum, len(scanner.Bytes()), maxLineLen)\n        }\n    }\n    return scanner.Err()\n}\n\n// Usage: checkLongLines(file, 64*1024) before building","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure code generators to wrap output at reasonable line lengths (e.g., 120 columns)","Move large embedded data (base64, JSON blobs) to separate files and use //go:embed","Avoid single-line string literals longer than 64KB in generated Go code","Run a pre-build linting step that checks for excessively long lines"],"tags":["go-compiler","go-ssa","file-system","code-generation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}