Skip to content
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

Data race runtime issue + Capture of 'buffer' with non-sendable type Warning #825

Open
4 tasks done
aiFigueiredo opened this issue Dec 19, 2024 · 0 comments
Open
4 tasks done

Comments

@aiFigueiredo
Copy link

aiFigueiredo commented Dec 19, 2024

New Issue Checklist

Steps to reproduce

The following code in a concurrent background thread produces a data race when the Thread Sanitizer is enabled:

struct ContactData {
    let number: [String]
}

let utility = PhoneNumberUtility()
let dataArray: [ContactData] = [...]

for item in dataArray {
    utility.parse(item.numbers)
}
Expected result

No warning, nor data race.

Actual result
  1. There is a data race accessing the hasError property:
    Screenshot 2024-12-19 at 22 15 41
Data race in closure #1 @Sendable (Swift.Int) -> () in closure #1 (inout Swift.UnsafeMutableBufferPointer<PhoneNumberKit.PhoneNumber>, inout Swift.Int) -> () in PhoneNumberKit.ParseManager.parseMultiple(_: Swift.Array<Swift.String>, withRegion: Swift.String, ignoreType: Swift.Bool, shouldReturnFailedEmptyNumbers: Swift.Bool) -> Swift.Array<PhoneNumberKit.PhoneNumber>

2, Opening the Project in Xcode 16.1 on master, shows a warning on line 112:
Screenshot 2024-12-19 at 22 14 27

Capture of 'buffer' with non-sendable type 'UnsafeMutableBufferPointer<PhoneNumber>' in a `@Sendable` closure; this is an error in the Swift 6 language mode

Environment

Xcode 16.1 + SPM (v4.0.1 / master)

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

No branches or pull requests

1 participant