Closed
Description
We have some code in Servo of the form:
match name.to_ascii_lower().as_slice() {
"margin-top" => // stuff
"margin-right" => // stuff
// dozens more of these
}
The match will sometimes (nondeterministically) fail even though name
matches one of the listed string literals. The bug apparently disappears if I change the code to
let name_lower = name.to_ascii_lower();
match name_lower.as_slice() {
So I believe the ~str
returned by to_ascii_lower()
is getting freed before the match
is done. (I couldn't reproduce the bug inside Valgrind, however.)
You can see the actual Servo code here. It's a Mako template which outputs Rust code. If you build Servo you can see the generated code at src/components/style/properties.rs
.
We're using
rustc 0.9-pre (67d7be0 2013-10-29 12:02:59 -0700)
so if you believe this bug is already fixed in master
, let us know and we can upgrade.