RFR: 8302670: use-after-free related to PhaseIterGVN interaction with Unique_Node_List and Node_Stack [v2]
Kim Barrett
kbarrett at openjdk.org
Thu May 18 10:44:57 UTC 2023
On Tue, 16 May 2023 16:15:16 GMT, Justin King <jcking at openjdk.org> wrote:
>> I took this from @jcking . From what I understand:
>> `NONCOPYABLE` disables the copy constructor (`&`) and move operator. Somehow, this also disables the move constructor (`&&`). Re-enabling that one allows things like returning local containers, and capturing them via that move constructor.
>>
>> Unique_Node_List some_function() {
>> Unique_Node_List local_worklist;
>> // do stuff
>> return local_worklist;
>> }
>>
>> void other_function() {
>> Unique_Node_List capture_worklist = some_function();
>> // capture_worklist has its scope widened to this function
>> }
>>
>> But if someone has a more detailed explanation, I'm glad to hear it ;)
>
> https://en.cppreference.com/w/cpp/language/move_constructor details this a bit by referencing the standard. When you explicitly define or delete the copy constructor, the move constructor is no longer implicitly defined and you have to explicitly default it or define it.
pedantic: s/explicitly default it or define it/explicitly define it (possibly with a default definition)/. But yes, that's
why the explicit definition is needed if you want to permit move of noncopyable (e.g. move-only).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13833#discussion_r1197644656
More information about the hotspot-dev
mailing list