# Arc::increment\_strong\_count design question (cross-post)

**URL:** <https://users.rust-lang.org/t/arc-increment-strong-count-design-question-cross-post/139708>\
**Category:** help\
**Created:** [April 22, 2026, 11:26am UTC](https://users.rust-lang.org/t/arc-increment-strong-count-design-question-cross-post/139708 "2026-04-22T11:26:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akrauze](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/akrauze/32/39129_2.png) [@akrauze](https://users.rust-lang.org/u/akrauze)\
**Post date:** [April 22, 2026, 11:26am UTC](https://users.rust-lang.org/t/arc-increment-strong-count-design-question-cross-post/139708/1 "2026-04-22T11:26:43Z")

</div>

**Cross-post** : This is a cross-post from [internals forum](https://internals.rust-lang.org/t/arc-increment-strong-count-design-question/24177). Since it got no replies for a week I think it is safe to cross-post it here, as there will be no discussion overlap.

* * *

I was reading docs of [`Arc::increment_strong_count`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.increment_strong_count) and in the safety section I found requirement that raw pointer passed to the function must point to valid allocation created by _global allocator_.

> The pointer must have been obtained through `Arc::into_raw` and must satisfy the same layout requirements specified in [`Arc::from_raw_in`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.from_raw_in). The associated `Arc` instance must be valid (i.e. the strong count must be at least 1) for the duration of this method, and `ptr` must point to a block of memory allocated by the global allocator.

This requirement surprised me, so I looked into implementation and after going though `Arc::increment_strong_count_in` layer I found that the implementation basically just creates `Arc` from raw pointer and clones it:

```rust
// Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
let arc = unsafe { mem::ManuallyDrop::new(Arc::from_raw_in(ptr, alloc)) };
// Now increase refcount, but don't drop new refcount either
let _arc_clone: mem::ManuallyDrop<_> = arc.clone();

```

Why does the implementation of `Arc::increment_strong_count` simply not walk pointers and increment strong count directly? Requiring `alloc` to be passed into `Arc::increment_strong_count` seams overly constraining, since at no point the allocator is used at all.

I understand why [`Arc::decrement_strong_count`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.decrement_strong_count) needs access to the allocator, as it needs to drop inner `T` and `ArcInner` when strong and weak counters go to 0. Was `Arc::increment_strong_count` designed in such way to keep symmetry with decrementing part? Or is there some safety invariant that I do not see, that would be violated if `Arc::increment_strong_count` would call `fetch_add` on the strong counter directly?

---

<div class="post-metadata">

**Author:** ![geebee22](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/geebee22/32/16527_2.png) [@geebee22](https://users.rust-lang.org/u/geebee22)\
**Post date:** [April 22, 2026, 11:38am UTC](https://users.rust-lang.org/t/arc-increment-strong-count-design-question-cross-post/139708/2 "2026-04-22T11:38:41Z")

</div>

I saw your post, and guessed someone better qualified to comment than myself would say something.

But FWIW I think you are right. I may well be wrong though, I haven't implemented Arc yet and thought about it in any detail. I don't have plans to implement it either, as I don't think Arc allocations are typically frequent.

Also, on unstable nightly, the memory could have come from any allocator, not necessarily Global. But that is perhaps some kind of nit-pick.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [July 21, 2026, 11:39am UTC](https://users.rust-lang.org/t/arc-increment-strong-count-design-question-cross-post/139708/3 "2026-07-21T11:39:00Z")

</div>

Closed on July 21, 2026, 11:39am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
