Hey p-a-d@,
Currently all garbage collected heap collections, such as `HeapVector`, are `DISALLOW_NEW()` and `GarbageCollected`. This allows them to be placed on stack, directly within other objects, and being dynamically allocated with `MakeGarbageCollected()`. This is not in line with Oilpan's general rules.
While this may be very convenient, it is prone for accidental misuses as it disables a bunch of static checks. E.g., it permits placing `HeapVector` on stack and referring to such an object via `Member`, which leads to memory corruptions. This has happened a few times and bugs generally have security implications. We also see people trying to infer best practices from the collection types which leads to confusion as rules are not consistently enforced.
We have been asked to strengthen static asserts and the GC plugin. Going forward, we will make Oilpan follow its own rules:
- Keep `HeapVector` and friends as `DISALLOW_NEW()`. This covers the vast majority of cases for which nothing needs to be done.
- Introduce wrapper types (e.g. `HeapVectorWrapper`, use the existing `DisallowNewWrapper`) that should be used when dynamically allocating collections. This requires migrating uses which should be trivial though.
This change is performance neutral and will not impose additional allocations.
Cheers, Michael