Repository: go
Issue: internal/coverage/cfile: TestCoverageApis/emitToFailingWriter failures
Labels: NeedsInvestigation

```
#!watchflakes
default <- pkg == "internal/coverage/cfile" && test == "TestCoverageApis/emitToFailingWriter"
```

Issue created automatically to collect these failures.

Example ([log](https://ci.chromium.org/b/8733069857189338673)):

    === RUN   TestCoverageApis/emitToFailingWriter
    === PAUSE TestCoverageApis/emitToFailingWriter
    === CONT  TestCoverageApis/emitToFailingWriter
        emitdata_test.go:166: running: /home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/build1/harness.exe -tp emitToFailingWriter -o /home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/emitToFailingWriter-edir-y with rdir=/home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/emitToFailingWriter-rdir-y and GOCOVERDIR=false
        emitdata_test.go:166: running: /home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/build1/harness.exe -tp emitToFailingWriter -o /home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/emitToFailingWriter-edir-x with rdir=/home/swarming/.swarming/w/ir/x/t/TestCoverageApis2055472943/001/emitToFailingWriter-rdir-x and GOCOVERDIR=true
        emitdata_test.go:343: 
            internal error in coverage meta-data tracking:
            encountered bad pkgID: 0  at slot: 3484  fnID: 6  numCtrs: 1
            list of hard-coded runtime package IDs needs revising.
            [see the comment on the 'rtPkgs' var in 
    ...
            panic: runtime error: slice bounds out of range [:4294969857] with capacity 27250
            
            goroutine 1 gp=0x40000021c0 m=2 mp=0x400005a808 [running]:
            panic({0x2ad880?, 0x40000181f8?})
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/panic.go:806 +0x578 fp=0x4000308930 sp=0x4000308880 pc=0x1a2c38
            runtime.goPanicSliceAcap(0x100000a01, 0x6a72)
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/panic.go:141 +0xc4 fp=0x4000308970 sp=0x4000308930 pc=0xc9e44
            internal/coverage/cfile.(*emitState).VisitFuncs(0x400009e140, 0x400000c0f0)
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/internal/coverage/cfile/emit.go:478 +0x1564 fp=0x4000308be0 sp=0x4000308970 pc=0x26e874
            internal/coverage/encodecounter.(*CoverageDataWriter).writeCounters(0x4000010140, {0x2eb140, 0x400009e140}, 0x40000a0120)
    ...
            runtime.gcBgMarkWorker(0x40000240e0)
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/mgc.go:1363 +0x2b8 fp=0x4000051fb0 sp=0x4000051f10 pc=0x64198
            runtime.gcBgMarkStartWorkers.gowrap1()
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/mgc.go:1279 +0x28 fp=0x4000051fd0 sp=0x4000051fb0 pc=0x63ea8
            runtime.goexit({})
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/asm_arm64.s:1260 +0x4 fp=0x4000051fd0 sp=0x4000051fd0 pc=0x1b1924
            created by runtime.gcBgMarkStartWorkers in goroutine 1
            	/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/mgc.go:1279 +0x3f4
        emitdata_test.go:344: running 'harness -tp emitToFailingWriter': exit status 2
    --- FAIL: TestCoverageApis/emitToFailingWriter (0.17s)


— [watchflakes](https://go.dev/wiki/Watchflakes)