3 ms·
Some classes of errors yes, but this still has a giant hole in it that the writeup calls out: "But there’s a hole in this scheme. We could copy an unrooted poi
by ianlevesque 12y ago
Some classes of errors yes, but this still has a giant hole in it that the writeup calls out:
"But there’s a hole in this scheme. We could copy an unrooted pointer — a JS<T> — to a local variable on the stack, and then at some later point, root it and use the DOM object. In the meantime, SpiderMonkey’s garbage collector won’t know about that JS<T> on the stack, so it might free the DOM object. To really be safe, we need to make sure that JS<T> only appears in traceable DOM structs, and never in local variables, function arguments, and so forth.
This rule doesn’t correspond to anything that already exists in Rust’s type system. Fortunately, the Rust compiler can load "lint plugins" providing custom static analysis. These basically take the form of new compiler warnings, although in this case we set the default severity to "error"."
Requiring additional layers of static analysis on top of unsafe code (and still not catching all the error cases) is beginning to sound an awful lot like plain old C or C++ again.
- pcwalton 12y agoI'm pretty sure that one can be fixed by enhancing the lint to actually look at inferred types. (This is easy to do.) In any case, empirically we have seen a lot fewer rooting errors (none, AFAIK) in Servo than we have in Gecko.