Skip to content

Concurrency question #2859

@macdrevx

Description

@macdrevx

Copilot Usage Confirmation

  • I have tried using GitHub Copilot to resolve this issue.

MSAL Version

2.5.1

Description

We're seeing some use-after-free crashes that seem to be related to multi-threaded use of MSALPublicClientApplication. To address this problem, I'm working on wrapping it in a Swift actor, and I'm curious about whether it's safe to call additional methods on MSALPublicClientApplication in between when one of its async methods is invoked and when that method's completion block is invoked.

For example, would the following sequence be safe?

// 1. invoke async method
publicClientApplication.acquireToken(with: parameters) {
    // 3. async method finishes
    ... completion ...
}

// 2. invoke another method
publicClientApplication.account(forIdentifier: identifier)

Or, for more complexity…

// 1. invoke async method
publicClientApplication.acquireToken(with: parameters) {
    // 3 or 4. async method finishes
    ... completion ...
}

// 2. invoke another method
publicClientApplication.acquireTokenSilent(with: parameters) {
    // 3 or 4. second async method finishes
    ... completion ...
}

How are situations like this handled by the SDK?

Error Details

n/a

MSAL Logs

n/a

Reproduction Steps

n/a

Expected Behavior

n/a

Regression

No response

Screenshots & Screen Recordings

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions