-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Badly behaved Encode and Decode impls for FileMap #42374
Comments
Side note: this unreachable is reachable. #![feature(rustc_private)]
extern crate syntax_pos;
extern crate serialize;
use syntax_pos::FileMap;
use serialize::{opaque, Decodable};
fn main() {
let bytes = [0, 0, 0, 0, 2, 0, 0];
let _ = FileMap::decode(&mut opaque::Decoder::new(&bytes, 0));
}
|
The tests here need to be updated; e.g. PR #52953 renamed #![feature(rustc_private)]
extern crate syntax_pos;
extern crate serialize;
use syntax_pos::SourceFile as FileMap;
use serialize::{opaque, Decodable};
fn main() {
let bytes = [0, 0, 0, 0, 2, 0, 0];
let _ = FileMap::decode(&mut opaque::Decoder::new(&bytes, 0));
} (or you can rename it in the code itself rather than use When you run it today, it does this:
which seems better than what @dtolnay was previously seeing. |
Updated test case: #![feature(rustc_private)]
extern crate rustc_span;
extern crate rustc_serialize;
use rustc_span::SourceFile as FileMap;
use rustc_serialize::{opaque, Decodable};
fn main() {
let bytes = [0, 0, 0, 0, 2, 0, 0];
let _ = FileMap::decode(&mut opaque::Decoder::new(&bytes, 0));
} This now panics with
as it detected an invalid string serialization. JSON deserialization support of rustc_serialize has been removed somewhat recently. Furthermore I don't think it is necessary for us to be robust against all corrupt metadata as we have to abort some way or another anyway. I think this issue should be closed. |
I agree. |
The impls added in #22235 violate some assumptions in libserialize by trying to serialize multiple values for the "lines" field. When decoding, it ends up hitting this unwrap.
This may not be important if it has worked for this long, but there may be other variations of this bug lurking elsewhere.
The text was updated successfully, but these errors were encountered: