Skip to content

grpc: fix bug causing an extra Read if a compressed message is the same size as the limit #8178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 18, 2025

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Mar 17, 2025

Fixes #8171

This is an alternate fix to the above issue as mentioned in #8172.

I'll add a test case that ensures Read is not called beyond io.EOF. But it looks like there might be some other problems with the tests in rpc_util_test.go, as several test cases are not setting the decompressor field dc, and I want to look at that more closely, too.

cc @jhump

RELEASE NOTES:

  • grpc: fix bug causing an extra Read if a compressed message is the same size as the limit

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.04%. Comparing base (1703656) to head (03ac458).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8178      +/-   ##
==========================================
- Coverage   82.11%   82.04%   -0.07%     
==========================================
  Files         410      410              
  Lines       40251    40251              
==========================================
- Hits        33051    33023      -28     
- Misses       5844     5862      +18     
- Partials     1356     1366      +10     
Files with missing lines Coverage Δ
rpc_util.go 82.24% <100.00%> (ø)

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arjan-bal
Copy link
Contributor

Talked offline, it would be much simpler to restrict the max message size to MaxUint64 - 1 and avoid more complicated handling here.

@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal Mar 18, 2025
@dfawley
Copy link
Member Author

dfawley commented Mar 18, 2025

Updated to use an io.LimitReader again.

@dfawley dfawley removed their assignment Mar 18, 2025
rpc_util_test.go Outdated
case <-ctx.Done():
t.Fatalf("Timed out waiting for call to compressor")
}
ctx, cancel = context.WithTimeout(ctx, 10*time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we define a defaultTestShortTimeout and use it here to avoid having tests using different wait durations later?

rpc_util_test.go Outdated
return m, nil
}

func (m *mockCompressor) Read(p []byte) (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Vet is mentioning that the variable name can be dropped.

@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal Mar 18, 2025
@dfawley dfawley merged commit 0af5a16 into grpc:master Mar 18, 2025
15 checks passed
@dfawley dfawley deleted the limit_reader branch March 18, 2025 22:08
dfawley added a commit to dfawley/grpc-go that referenced this pull request Mar 18, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Mar 24, 2025
@arjan-bal arjan-bal modified the milestones: 1.72 Release, 1.71 Release Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in gzip compressor, possibly due to incorrect concurrent use
2 participants