Skip to content

Support detached threads still running when the main thread exits ("thread leaks") #1371

Open
@RalfJung

Description

@RalfJung

With #1284 we can run multi-threaded programs in Miri. However, right now we error if, when the main thread exits, there are any other threads still left. We should properly support that case.

For that, we need to:

  • not complain about memory reachable from those threads as leaking.
  • figure out what the semantics are wrt. TLS dtors. I assume those do not run for threads that are still around (after all the thread might be working on that piece of TLS right now, so a dtor would find it in an inconsistent state), but we should confirm that and leave appropriate comments.
  • decide what to do about non-detached threads still running when the main thread exits. I am inclined to call those threads a leak, but maybe if they were spawned by a detached thread it's okay? IMO we should report a leak when e.g. the main thread spawns a thread and then neither detaches nor joins it.

Cc @vakaras

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: affects our concurrency (multi-thread) supportC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions