You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
since thread_info is a member of this, and declared as a plain const ThreadInfo*, after this call, it refers to an unowned pointer... the ownership is in the returned unique_ptr. Since the only two call sites immediately assign the result to a local unique_ptr, this member var is guaranteed to be stale at the end of the calling routine.
I'm not sure what the right fix is here because I don't know the intended semantics -- shared_ptr might be appropriate, but it's not clear to me whether the returned result is intended to be mutable or not, or what constraints there are on mutability.
The current code looks absolutely unsafe, however, and needs fixing; if there are similar code patterns elsewhere in this codebase, they need examination as well.
The text was updated successfully, but these errors were encountered:
While investigating #7606 I noticed this code in the Anderson2021 codebase:
since
thread_info
is a member ofthis
, and declared as a plainconst ThreadInfo*
, after this call, it refers to an unowned pointer... the ownership is in the returned unique_ptr. Since the only two call sites immediately assign the result to a local unique_ptr, this member var is guaranteed to bestale
at the end of the calling routine.I'm not sure what the right fix is here because I don't know the intended semantics --
shared_ptr
might be appropriate, but it's not clear to me whether the returned result is intended to be mutable or not, or what constraints there are on mutability.The current code looks absolutely unsafe, however, and needs fixing; if there are similar code patterns elsewhere in this codebase, they need examination as well.
The text was updated successfully, but these errors were encountered: