Skip to content

Arithmetic overflow when recording mailboxCount metric during shutdown #802

@budde

Description

@budde

It appears that in some cases an actor's Mailbox can shut down with more processedActivations than initial messages for a given run. This results in an arithmetic error when trying to record the mailboxCount metric when the mailbox is shutting down:

0x7f10e50fa97f 0x55d9e6c13c4f, Swift runtime failure: arithmetic overflow at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/Mailbox.swift:0 0x55d9e6c13c4f, DistributedActors.Mailbox.(mailboxRun in _F5A1B51A24FD9930199EBF91BB3C2562)(DistributedActors.ActorShell<A>) -> DistributedActors.Mailbox<A>.(MailboxRunResult in _F5A1B51A24FD9930199EBF91BB3C2562) at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/Mailbox.swift:489 0x55d9e6c12208, DistributedActors.Mailbox.run() -> () at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/Mailbox.swift:333 0x55d9e6997a66, reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /workspace/<compiler-generated>:0 0x55d9e6bfae0d, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /workspace/<compiler-generated>:0 0x55d9e6bfb1b9, reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> () at .build/checkouts/swift-distributed-actors/Sources/DistributedActors/locks.swift:0 0x55d9e6bfb1b9, closure #1 () -> () in DistributedActors.FixedThreadPool.init(Swift.Int) throws -> DistributedActors.FixedThreadPool at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/FixedThreadPool.swift:75 0x55d9e6cbc969, closure #1 () -> () in DistributedActors.Thread.init(() -> ()) throws -> DistributedActors.Thread at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/Thread.swift:53 0x55d9e6cbc969, partial apply forwarder for closure #1 () -> () in DistributedActors.Thread.init(() -> ()) throws -> DistributedActors.Thread at /workspace/<compiler-generated>:0 0x55d9e6cbc45f, closure #1 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in static DistributedActors.Thread.runnerCallback.getter : @convention(c) (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.Optional<Swift.UnsafeMutableRawPointer> at /workspace/.build/checkouts/swift-distributed-actors/Sources/DistributedActors/Thread.swift:132 0x7f10e50ef6da 0x7f10e327e71e 0xffffffffffffffff 

We can add a mitigation for this behavior while investigating the root cause that is triggering it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions