Slice::len returns zero for pool-backed slices
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- networking
Research direction
Start at slice.rs:106-110 and inspect how Slice::len handles owned and pool-backed slices. Trace BufferPool::get_data_owned and binary_sv2's GetSize for Slice to understand the affected path. Done means pool-backed len() returns the stored len and agrees with as_ref().len(), including for non-empty received frames.
Written by the indexing model from the issue text.
Description
Slice::len (slice.rs:106-110) reads the backing Vec only when owned is Some; every pool-backed slice reports zero even though its len field is set and AsRef<[u8]> exposes the whole payload. BufferPool::get_data_owned produces exactly these slices, and binary_sv2's GetSize for Slice forwards to the same method, so a non-empty received frame passes any len() <= limit or is_empty() check as if it had no bytes and is then processed in full through as_ref(). Distinct from #2352, which is get_data_by_ref ignoring its argument.
Fix: return the stored len for pool-backed slices, so len() and as_ref().len() agree in every mode.
- Dominant language
- Rust
- Stars
- 352
- Forks
- 200
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stratum-mining/stratum
-
MessageFrame::encode_into accepts a serializer that writes fewer bytes than the header declares Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
stratum-mining/stratum#2386 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
stratum-mining/stratum#2385 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
stratum-mining/stratum#2384 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
stratum-mining/stratum#2381 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
stratum-mining/stratum#2376 ·
All issues in stratum-mining/stratum
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100