Skip to content

Commit

Permalink
argue why at_exit_imp is fine
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 6, 2018
1 parent 22457de commit ab3e4a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libstd/sys_common/at_exit_imp.rs
Expand Up @@ -64,6 +64,7 @@ pub fn cleanup() {
if !queue.is_null() {
let queue: Box<Queue> = Box::from_raw(queue);
for to_run in *queue {
// We are not holding any lock, so reentrancy is fine.
to_run();
}
}
Expand All @@ -75,9 +76,8 @@ pub fn push(f: Box<dyn FnBox()>) -> bool {
unsafe {
let _guard = LOCK.lock();
if init() {
// This could reentrantly call `push` again, which is a problem because
// `LOCK` allows reentrancy!
// FIXME: Add argument why this is okay.
// We are just moving `f` around, not calling it.
// There is no possibility of reentrancy here.
(*QUEUE).push(f);
true
} else {
Expand Down

0 comments on commit ab3e4a2

Please sign in to comment.