{"record":{"id":"19db9441a89b8766","repo":"AlexxIT/go2rtc","slug":"probe-reader-overflow","errorCode":null,"errorMessage":"probe reader overflow","messagePattern":"probe reader overflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/core/readbuffer.go","lineNumber":63,"sourceCode":"\t// if buffer not empty - read from it\n\tif r.pos < len(r.buf) {\n\t\tn = copy(p, r.buf[r.pos:])\n\t\tr.pos += n\n\t\treturn\n\t}\n\n\t// with negative buffer - empty it and read as usual\n\tif r.BufferSize < 0 {\n\t\tr.BufferSize = BufferDisable\n\t\tr.buf = nil\n\t\tr.pos = 0\n\n\t\treturn r.Reader.Read(p)\n\t}\n\n\tn, err = r.Reader.Read(p)\n\tif len(r.buf)+n > r.BufferSize {\n\t\treturn 0, errors.New(\"probe reader overflow\")\n\t}\n\tr.buf = append(r.buf, p[:n]...)\n\tr.pos += n\n\treturn\n}\n\nfunc (r *ReadBuffer) Close() error {\n\tif closer, ok := r.Reader.(io.Closer); ok {\n\t\treturn closer.Close()\n\t}\n\treturn nil\n}\n\nfunc (r *ReadBuffer) Seek(offset int64, whence int) (int64, error) {\n\tvar pos int\n\tswitch whence {\n\tcase io.SeekStart:\n\t\tpos = int(offset)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/core/readbuffer.go#L45-L81","documentation":"pkg/core/readbuffer.go:63 implements a probe reader that records every byte it reads into an internal buffer, capped at r.BufferSize. When a single Read would push the recorded buffer beyond BufferSize (len(r.buf)+n > r.BufferSize), it refuses the read and returns \"probe reader overflow\". This is a library-internal invariant: the probe detection logic expected media probing to finish within a bounded number of bytes.","triggerScenarios":"Any Read on the probe reader whose accumulated bytes plus the incoming chunk exceed r.BufferSize; triggered from TestReadSeeker or media probing when the source streams more data than the probe window before the format could be identified.","commonSituations":"Probing a media source with very large headers or no early recognizable format signature; misconfigured BufferSize too small for the container format; a source that never yields probeable data so the buffer fills to the cap.","solutions":["Increase BufferSize on the probe reader so it can hold enough bytes for your container's headers.","Verify the media source is actually the expected format (a garbage/garbled stream may never be recognized).","Check that the source produces a proper probeable stream (correct container, valid headers).","If probing an unusual source (e.g. raw streams), bypass probing by declaring the codec explicitly."],"exampleFix":"// before\ncore.NewProbeReader(rs, 4096)\n// after: larger probe window for sources with long headers\ncore.NewProbeReader(rs, 512*1024)","handlingStrategy":"validation","validationCode":"// ensure the probe window is large enough before probing\nif probeReader.BufferSize < 512*1024 {\n    probeReader = core.NewProbeReader(rs, 512*1024)\n}","typeGuard":null,"tryCatchPattern":"n, err := probeReader.Read(p)\nif err != nil && err.Error() == \"probe reader overflow\" {\n    return fmt.Errorf(\"media source exceeded probe window (%w); enlarge BufferSize or check source format\", err)\n}","preventionTips":["Size BufferSize generously for containers with long headers","Only probe sources expected to be valid media","Declare codecs explicitly for raw/non-probeable streams","Unit-test probe limits with your real source types"],"tags":["media","probing","buffer","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}