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

Workaround for https://github.com/apple/swift/issues/73532 #4951

Closed
wants to merge 1 commit into from

Conversation

hjyamauchi
Copy link
Contributor

Increase the initial size of __CFReadSocketsFds to reduce the chance of resizing it which appears to lead to compiler hangs.

Increase the initial size of __CFReadSocketsFds to reduce the chance
of resizing it which appears to lead to compiler hangs.
@hjyamauchi
Copy link
Contributor Author

CC @compnerd

@hjyamauchi
Copy link
Contributor Author

hjyamauchi commented May 9, 2024

Context: we are experiencing a occasional swift compiler hang issue on Windows on many-core machines. We have so far narrowed it down to dropped socket file descriptors due to some sort of data corruption in the __CFReadSocketsFds bit vector. Though we haven't fully figured it out, this change seems to be a reliable workaround for it.

The details are described at swiftlang/swift#73532

Copy link
Contributor

@tristanlabelle tristanlabelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that @lxbndr pointed to in this comment means that the CFSocket code is mixing up its handling of fd_set on Windows:

  • Platform macros FD_SET and FD_ISSET will know that fd_set is a struct on Windows,
  • CFSocket code will assume it is a bitset for resizing purposes.

The change here will create an allocation big enough so that the CFSocket bitlogic doesn't think it has to resize the allocation, but it will still be doing incorrect bit-level logic on the fd_set. I think we should build on @lxbndr's suggested fix. It would help to avoid defining fd_mask on Windows at all to find the places where we are treating an fd_set as a bitfield.

@hjyamauchi
Copy link
Contributor Author

Closing in favor of #4954

@hjyamauchi hjyamauchi closed this May 17, 2024
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