--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAHOQ7J9Zng8Z1BxHPh9jnABi%2B38x30pkvSODL7MnzmydtUU%3DXQ%40mail.gmail.com.
Could you explain the use case?
On Thu, Jan 27, 2022 at 10:19 AM <dan...@chromium.org> wrote:
PropertyTrees, and the types it contains, currently have virtually no protections against misuse. That is an obstacle to the project I am working on: Non-Blocking Commit.
Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?
On Thu, Jan 27, 2022 at 11:43 AM <dan...@chromium.org> wrote:Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?STACK_ALLOCATED() prevents this:class Dangerous {STACK_ALLOCATED();};class LongLived {Dangerous dangerous_;};I'm not aware of another mechanism to prevent this; simply deleting 'operator new' is not sufficient.
On Thu, Jan 27, 2022 at 11:48 AM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:43 AM <dan...@chromium.org> wrote:Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?STACK_ALLOCATED() prevents this:class Dangerous {STACK_ALLOCATED();};class LongLived {Dangerous dangerous_;};I'm not aware of another mechanism to prevent this; simply deleting 'operator new' is not sufficient.Here's how that is enforced by blink_gc_plugin:
On Thu, Jan 27, 2022 at 2:50 PM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:48 AM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:43 AM <dan...@chromium.org> wrote:Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?STACK_ALLOCATED() prevents this:class Dangerous {STACK_ALLOCATED();};class LongLived {Dangerous dangerous_;};I'm not aware of another mechanism to prevent this; simply deleting 'operator new' is not sufficient.Here's how that is enforced by blink_gc_plugin:Thanks, I was thinking of ANNOTATE_STACK_ALLOCATED, it turns out.So this prevents composition of STACK_ALLOCATED into non-STACK_ALLOCATED. There's nothing blink or gc specific about that, so moving it out of blink seems okay to me.But what about ANNOTATE_STACK_ALLOCATED? There's no comments about these but do they need to go together?
Aside: Does it also prevent inheritance from STACK_ALLOCATED?
On Thu, Jan 27, 2022 at 11:54 AM <dan...@chromium.org> wrote:On Thu, Jan 27, 2022 at 2:50 PM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:48 AM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:43 AM <dan...@chromium.org> wrote:Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?STACK_ALLOCATED() prevents this:class Dangerous {STACK_ALLOCATED();};class LongLived {Dangerous dangerous_;};I'm not aware of another mechanism to prevent this; simply deleting 'operator new' is not sufficient.Here's how that is enforced by blink_gc_plugin:Thanks, I was thinking of ANNOTATE_STACK_ALLOCATED, it turns out.So this prevents composition of STACK_ALLOCATED into non-STACK_ALLOCATED. There's nothing blink or gc specific about that, so moving it out of blink seems okay to me.But what about ANNOTATE_STACK_ALLOCATED? There's no comments about these but do they need to go together?ANNOTATE_STACK_ALLOCATED exists only to support the enforcement of STACK_ALLOCATED, by applying a custom __attribute__ that blink_gc_plugin looks for. So yes, I think they need to move together. Presumably we'd choose a more generic label for the __attribute__, and modify blink_gc_plugin to search for the new label.
On Thu, Jan 27, 2022 at 3:23 PM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:54 AM <dan...@chromium.org> wrote:On Thu, Jan 27, 2022 at 2:50 PM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:48 AM Stefan Zager <sza...@chromium.org> wrote:On Thu, Jan 27, 2022 at 11:43 AM <dan...@chromium.org> wrote:Dodging the larger question about memory safety and lifetimes here, my understanding of the STACK_ALLOCATED macro is to tell the GC plugin that the class doesn't need a Trace() method. But the Trace() requirement is only needed for blink types, and these aren't blink types. Could you clarify what is preventing you from doing this without STACK_ALLOCATED?STACK_ALLOCATED() prevents this:class Dangerous {STACK_ALLOCATED();};class LongLived {Dangerous dangerous_;};I'm not aware of another mechanism to prevent this; simply deleting 'operator new' is not sufficient.Here's how that is enforced by blink_gc_plugin:Thanks, I was thinking of ANNOTATE_STACK_ALLOCATED, it turns out.So this prevents composition of STACK_ALLOCATED into non-STACK_ALLOCATED. There's nothing blink or gc specific about that, so moving it out of blink seems okay to me.But what about ANNOTATE_STACK_ALLOCATED? There's no comments about these but do they need to go together?ANNOTATE_STACK_ALLOCATED exists only to support the enforcement of STACK_ALLOCATED, by applying a custom __attribute__ that blink_gc_plugin looks for. So yes, I think they need to move together. Presumably we'd choose a more generic label for the __attribute__, and modify blink_gc_plugin to search for the new label.We may be getting lost in details, but STACK_ANNOTATED puts a type alias inside the class that the plugin looks for: https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/blink_gc_plugin/RecordInfo.cpp;drc=1044dd49d7d78fba1e11a1cdb27e4e0f6d193ef9;l=261It looks for that annotation on methods, when the type alias isn't found: https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/blink_gc_plugin/RecordInfo.cpp;l=278I now see STACK_ALLOCATED does both.. but I don't understand why.
The AppRegistryCache::ForOneApp(const std::string& app_id, FunctionType f) interface could use STACK_ALLOCATED() to protect against dangling references. This would enable it to return a value instead of taking a callback param.On Friday, 28 January 2022 at 11:43:12 am UTC+11 Kentaro Hara wrote:+1 to moving STACK_ALLOCATED() to //base/.However, the main benefit of STACK_ALLOCATED() is to prevent programming errors about Oilpan (though I agree that there are non-Oilpan-related benefits as Stefan pointed out). I think it's great to start using STACK_ALLOCATED() in some key classes in Chromium but I'm not sure if it's worth introducing STACK_ALLOCATED() throughout the existing codebase proactively.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/c33403a7-e157-404a-9d35-ba3274653604n%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAH%2BmL5B61g%3DEnK2jtE3ucQ0n4uhBmSypy37M4NV%3DiA%3D57BTuqQ%40mail.gmail.com.