-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Arc::drop has a (potentially) dangling shared ref #55005
Copy link
Copy link
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-langRelevant to the language teamRelevant to the language teamT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]WG-embeddedWorking group: Embedded systemsWorking group: Embedded systems
Description
Activity
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-langRelevant to the language teamRelevant to the language teamT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]WG-embeddedWorking group: Embedded systemsWorking group: Embedded systems
Discovered by @Amanieu on IRLO. Quoting their report:
Arc::dropcontains this code:Once the current thread (Thread A) has decremented the reference count, Thread B could come in and free the
ArcInner.The problem becomes apparent when you look at the implementation of
fetch_sub:Note the point marked HERE: at this point we have released our claim to the
Arc(as in, decremented the count), which means that Thread B might have freed theArcInner. However the&selfstill points to the strong reference count in theArcInner-- so&selfdangles.Other instances of this: