]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.20] cmd/internal/cov: fix misuse of bufio.Reader.Read in read...
authorThan McIntosh <thanm@google.com>
Wed, 8 Feb 2023 20:06:08 +0000 (15:06 -0500)
committerThan McIntosh <thanm@google.com>
Wed, 22 Feb 2023 20:38:53 +0000 (20:38 +0000)
commitac556f35a27dbd73372af4088b89df4d61ab74e8
treea9c50809bf33fee91221a5713457551cb46c4e66
parent1acd39cc92cea4937fe9530c7d9bbce4711fc41c
[release-branch.go1.20] cmd/internal/cov: fix misuse of bufio.Reader.Read in read helper

Fix a misuse of bufio.Reader.Read in the helper class
cmd/internal/cov.MReader; the MReader method in question should have
been using io.ReadFull (passing the bufio.Reader) instead of directly
calling Read.

Using the Read method instead of io.ReadFull will result in a "short"
read when processing a specific subset of counter data files, e.g.
those that are short enough to not trigger the mmap-based scheme we
use for larger files, but also with a large args section (something
large enough to exceed the default 4k buffer size used by
bufio.Reader).

Along the way, add some additional defered Close() calls for files
opened by the CovDataReader.visitPod, to enure we don't leave any open
file descriptor following a call to CovDataReader.Visit.

Fixes #58427.
Updates #58411.

Change-Id: Iea48dc25c0081be1ade29f3a633df02a681fd941
Reviewed-on: https://go-review.googlesource.com/c/go/+/466677
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
(cherry picked from commit a7fe9ada10c02a7ea61b2909ef7db151d290073f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/468536
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/internal/cov/mreader.go
src/cmd/internal/cov/read_test.go [new file with mode: 0644]
src/cmd/internal/cov/readcovdata.go
src/cmd/internal/cov/testdata/small.go [new file with mode: 0644]