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
Jumping on uninitalized value #421
Comments
@Kixiron Do you have a public codebase that reproduces the error that I can refer to? |
I've tried running https://github.com/jyn514/html5ever-example/blob/master/src/struct.CaptureMatches.html through a kuchiki example program under valgrind, and I don't see the error you reported. A minimal program that reproduces the error would be most useful for me. |
The code's all on this branch, I made a minimal reproduction with this being all the parse-related code. For reproduction steps I simply ran |
Me running that binary gives this output
|
Oh, interesting, I can reproduce the same problem in the kuchiki example when running with --release, but not with a debug build. |
Same on my end, debug builds have no issues |
These sorts of errors are typically because LLVM has made valid optimizations but valgrind doesn’t/can’t understand that, so valgrind flags a potential error. |
Also interesting - when I add a println above this line for |
Rewriting the match as a series of equivalent if let and if statements does not change the valgrind output. |
The following diff makes the error disappear: diff --git a/html5ever/src/tree_builder/data.rs b/html5ever/src/tree_builder/data.rs
index 9d51a71..5e84200 100644
--- a/html5ever/src/tree_builder/data.rs
+++ b/html5ever/src/tree_builder/data.rs
@@ -147,14 +147,14 @@ pub fn doctype_error_and_quirks(doctype: &Doctype, iframe_srcdoc: bool) -> (bool
let public = opt_to_ascii_lower(public);
let system = opt_to_ascii_lower(system);
- let quirk = match (opt_string_as_slice(&public), opt_string_as_slice(&system)) {
+ let quirk = match (opt_string_as_slice(&public), &system) {
_ if doctype.force_quirks => Quirks,
_ if name != Some("html") => Quirks,
_ if iframe_srcdoc => NoQuirks,
(Some(ref p), _) if QUIRKY_PUBLIC_MATCHES.contains(p) => Quirks,
- (_, Some(ref s)) if QUIRKY_SYSTEM_MATCHES.contains(s) => Quirks,
+ (_, Some(ref s)) if QUIRKY_SYSTEM_MATCHES.contains(&&**s) => Quirks,
(Some(p), _) if contains_pfx(QUIRKY_PUBLIC_PREFIXES, p) => Quirks,
(Some(p), _) if contains_pfx(LIMITED_QUIRKY_PUBLIC_PREFIXES, p) => LimitedQuirks, |
This is a minimal reproduction of the same problem. I'll try filing it on rustc and see if anything comes of it: fn main() {
let mut args = std::env::args();
let s1 = args.next();
let s2 = args.next();
let a_matches = &["a"];
let b_matches = &["b"];
let a = s1.as_ref().map(|s| &s[..]);
let b = s2.as_ref().map(|s| &s[..]);
match (a, b) {
(Some(ref a), _) if a_matches.contains(a) => println!("a"),
(_, Some(ref b)) if b_matches.contains(b) => println!("b"),
_ => println!("nothing"),
}
} |
Filed rust-lang/rust#73344. |
Given rust-lang/rust#73344 (comment), I suspect the answer here is to update valgrind and leave the html5ever code unchanged. |
While running valgrind on my program, I found this
gdb then pointed out the source of the problem, which is this snippet
The text was updated successfully, but these errors were encountered: