It's currently possible to use std::make_unique to allocate an Oilpan object. However, Oilpan objects should never have their lifetime externally managed except through an Oilpan aware smart pointer such as Persistent.
We should figure out some way to disallow this / make it not compile.
- The most type-safe approach would be to wrap Oilpan pointers in a smart pointer template type and require that they be instantiated by a WTF:::MakeGarbageCollected (for example) call. However, my understanding is that wrapping all Oilpan pointers in wrappers was unacceptable from a performance perspective (and that is one reason we use conservative stack scanning rather than precise).
- Another approach is to just try to block use of dangerous ownership-taking functions with Oilpan types.
- A final approach would be to try to force Oilpan ctors/dtors to be private. For dtors, Oilpan objects would have to friend the appropriate class for destruction, and destruction would have to be funneled through one place.
Comment 1 by dcheng@chromium.org
, Aug 22 2017