pcap: tests fail on windows if TestPcapFileRead runs after TestBPFInstruction
- Dominant language
- Go
- Stars
- 6.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
This failure can be demonstrated by either just `go test -count=2` to catch it on the second iteration, or by adding the following test and running it alone with `go test -run TestBPFInstructionThenPcapFileRead`.
```
func TestBPFInstructionThenPcapFileRead(t *testing.T) {
for _, test := range []struct {
name string
fn func(*testing.T)
}{
{"BPFInstruction", TestBPFInstruction},
{"PcapFileRead", TestPcapFileRead},
} {
t.Run(test.name, test.fn)
}
}
```
The result of either of these is
```
exit status 0xc0000374
FAIL github.com/google/gopacket/pcap 0.393s
```
Reversing the order of the tests in `TestBPFInstructionThenPcapFileRead` results in test success.
I have narrowed this down to accessing `p.data` in `*packet.packetDump`; presumably the slice here reaches beyond its allocation. At the other end of the causal chain, running `*Handle.NewBPFInstructionFilter` with a non-empty set of instructions is enough to trigger the failure.
For purposes of replicability, the npcap I am using is 1.55 (https://nmap.org/npcap/dist/npcap-1.55.exe).
```
$ go version
go version go1.17.2 darwin/amd64
```
Contributor guide
Assessment
This issue has not been assessed yet.