10000 add additional location tracking to `Arc`, `alloc`, and `mpsc` by hawkw · Pull Request #265 · tokio-rs/loom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add additional location tracking to Arc, alloc, and mpsc #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 9, 2022

Conversation

hawkw
Copy link
Member
@hawkw hawkw commented May 4, 2022

Motivation

Currently, loom's mock Arc will track the source code location where
the Arc was created. This is useful for diagnosing problems, but it
isn't always enough to make the output easy to understand.

In particular, LOOM_LOG=trace will indicate where the Arc was
created, and will log ref count operations on that Arc. The creation
location is useful , but ref count operations aren't associated with a
location --- so a user reading the log cannot determine where the
Arc's reference count was incremented or decremented from. This makes
tracking leaks difficult.

Additionally, in the LOOM_LOG output, each Arc instance is
identified by its Ref (an index in the store of loom object states).
This permits tracking an individual Arc's refcount lifecycle in the
logs. However, when a leak is detected, the panic message does not
include this index, so it's not possible to determine which particular
Arc was leaked. The location where the Arc was created is included,
but multiple Arcs may have originated from the same location.

Solution

This branch improves Arc debuggability by adding location tracking to
operations that increment and decrement the Arc's reference count. It
also adds the index in the object store to the panic message when a leak
is detected, so the user can now go back and look for all the events for
the Arc instance with that ID. This should make debugging Arc leaks
much easier.

Similarly, I've also added location tracking to Loom's alloc and
mpsc mocks, and modified their panic messages to print the store index
as well.

@hawkw hawkw requested review from carllerche and Darksonn May 4, 2022 18:29
@hawkw hawkw enabled auto-merge (squash) May 4, 2022 19:17
hawkw added 6 commits May 4, 2022 12:24
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This allows it to be distinguished from other arcs from the same
location.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw force-pushed the eliza/track-refcounts branch from fde0313 to 38ad8a6 Compare May 4, 2022 19:24
@hawkw hawkw disabled auto-merge May 8, 2022 18:05
@hawkw hawkw enabled auto-merge (squash) May 8000 8, 2022 18:05
@hawkw hawkw merged commit 945c11a into master May 9, 2022
@hawkw hawkw deleted the eliza/track-refcounts branch May 9, 2022 17:47
hawkw added a commit that referenced this pull request May 10, 2022
# 0.5.5 (May 10, 2022)

### Added

- sync: Add `Arc::from_std` without `T: Sized` bound (#226)
- sync: Implement `Debug` for `AtomicPtr` for all `T` (#255)
- logs: Add location tracking for threads and atomic operations (#258)
- logs: Add additional location tracking to `Arc`, `alloc`, and `mpsc`
  (#265)
- logs: Improve `tracing` configuration for `LOOM_LOG` (#266)
- logs: Add a span for the current model's iteration (#267)

### Documented

- Add note about in-memory representation of atomic types (#253)
- Document `LOOM_LOG` syntax (#257)

### Fixed

- Fix double panic when exceeding the branch limit in `Drop` (#245)
- cell: Allow using `{Mut,Const}Ptr::{deref,with}` when the pointee is
  `!Sized` (#247)
- thread: Fix semantics of `thread::park` after `Thread::unpark` (#250)
@hawkw hawkw mentioned this pull request May 10, 2022
hawkw added a commit that referenced this pull request May 13, 2022
# 0.5.5 (May 10, 2022)

### Added

- sync: Add `Arc::from_std` without `T: Sized` bound (#226)
- sync: Implement `Debug` for `AtomicPtr` for all `T` (#255)
- logs: Add location tracking for threads and atomic operations (#258)
- logs: Add additional location tracking to `Arc`, `alloc`, and `mpsc`
  (#265)
- logs: Improve `tracing` configuration for `LOOM_LOG` (#266)
- logs: Add a span for the current model's iteration (#267)

### Documented

- Add note about in-memory representation of atomic types (#253)
- Document `LOOM_LOG` syntax (#257)

### Fixed

- Fix double panic when exceeding the branch limit in `Drop` (#245)
- cell: Allow using `{Mut,Const}Ptr::{deref,with}` when the pointee is
  `!Sized` (#247)
- thread: Fix semantics of `thread::park` after `Thread::unpark` (#250)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0