Comments (8)
@jieyouxu just tested with 1.76.0 and the regression was there so updated the comment and title
from rust.
This is failing with a failed to fill whole buffer
message, which points at read_exact
, not read_to_end
. So it's probably not #118222
The false branch in that match is kind of sus anyway. Turning a single read
call into multiple read*
calls can lead to bytes from an earlier call getting dropped when a later one returns an error. But I haven't analyzed the code yet, so it might not be relevant here.
Edit: Oh I see it's a bisection result. I'll take another look.
from rust.
searched nightlies: from nightly-2023-11-11 to nightly-2024-02-01
regressed nightly: nightly-2023-11-30
searched commit range: 5facb42...b10cfcd
regressed commit: bbefc98
bisected with cargo-bisect-rustc v0.6.8
Host triple: aarch64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --start=1.75.0 --end=1.77.1 -- test
from rust.
I'm going to guess it's #118222 cc @the8472. Pinging because not sure if the change in observable behavior here is intended.
from rust.
I did some testing for what types of Vec
initialization this code actually panics and found these results:
// 1.75.0 panic, 1.76.0 panic
let mut v = Vec::new();
// 1.75.0 panic, 1.76.0 panic
let mut v = Vec::with_capacity(7);
// 1.75.0 NO panic, 1.76.0 panic
let mut v = Vec::with_capacity(8);
Looking at these results I would guess that the old behavior was actually wrong and that it got fixed.
from rust.
@konsti219 looks like initialisation is needed now e.g like vec![0; 12]
so that is a fix if using read_exact
however read_to_end
is still broken
from rust.
Ok, I had a closer look at the code.
The issue is with both the read
function and with the test.
A) The test assumes that read_to_end
would pass in the Vec's spare capacity to the reader. This is not guaranteed. Both the current and the previous impl used a stack buffer for probing, #118222 just changed when the probing happens.
B) The read function does not handle large buffers getting passed in properly.
let len = buf.len();
let to_end = (self.first_len - self.pos) as usize;
match to_end >= len {
true => self.first.read(buf)?,
false => {
let mut first = vec![0; to_end];
let mut second = vec![0; len - to_end];
self.first.read_exact(&mut first)?;
sec.read_exact(&mut second)?;
first.append(&mut second);
first.as_slice().read(buf)?
With buf: &mut [u8; 32]
then len == 32
. In the test to_end = 8 - 0 = 8
. Therefore the false
case is taken.
Now second = vec![0; 32 - 8]
, 24 bytes.
But sec
is only 4 bytes long.
Therefore read_exact
fails.
So the change in the read_to_end impl merely uncovered preexisting bug in your code.
from rust.
So the change in the
read_to_end
impl merely uncovered preexisting bug in your code.
thanks so much @the8472 - so it was that buf is now not always guaranteed to match the vec capacity which also exposed bad parity with large buffers
changing to this now allows passing the test :)
let len = buf.len() as u64;
let to_end = self.first_len - self.pos;
match to_end >= len {
true => self.first.read(buf)?,
false => {
let mut first = vec![0; to_end as usize];
let excess = len - to_end;
let mut second = vec![
0;
match excess > self.second_len {
true => self.second_len,
false => excess,
} as usize
];
self.first.read_exact(&mut first)?;
sec.read_exact(&mut second)?;
first.append(&mut second);
first.as_slice().read(buf)?
}
}
thank you so much - this turned out to be an improvement rather than a regression
from rust.
Related Issues (20)
- ICE : non-eager expansion without a parent scope
- ICE : no entry found for key HOT 1
- target aarch64-linux-android Compilation error HOT 2
- Tracking Issue for Rust 2024: Make `unsafe_op_in_unsafe_fn` warn-by-default HOT 4
- ICE: rustc_abi `the len is 0 but the index is 0` calculating offset HOT 3
- Reasons for feature removals are not translatable
- Borrow incorrectly "escapes" function when calling method of blanket impl for `'static` type HOT 3
- "undefined reference to `WaitOnAddress'" error with nightly toolchain nightly-2024-03-28 on Windows GNU target HOT 2
- error[E0275]: overflow evaluating the requirement… when importing bevy_ecs HOT 2
- Missed Optimization when Matching on Complete Unicode Character Ranges with an Unreachable Arm HOT 1
- Missed optimization with reserve and extend_from_slice
- --crate-type=bin causes no_mangle symbols to be ommitted. HOT 4
- Internal compiler error when copying value of normally copyable type under `no_core` HOT 1
- ICE: `type variables should not be hashed?` HOT 1
- ICE: const generic with default const expr specified before type generic causes compiler to crash HOT 1
- ICE: virtual-function-elimination HOT 1
- rust-1.72.1 Unable to compile HOT 2
- ICE when using offset_of! in generic_const_exprs
- Miri reports leak in thread local allocation HOT 4
- Upgrade the Node.js version to 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.