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

[SR-14905] Swift NIO doesn't build with trunk stdlib on linux: recent stdlib fix may be breaking other things #57252

Closed
finagolfin opened this issue Jul 9, 2021 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@finagolfin
Copy link
Contributor

Previous ID SR-14905
Radar rdar://problem/80383590
Original Reporter @buttaface
Type Bug
Status Closed
Resolution Done
Environment

Fedora Core 33

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @glessard
Priority Medium

md5: 24c61965243cfe4ee49cf34fc02b7b66

Issue Description:

I hit this when just trying to build Swift NIO trunk with the official July 7 trunk snapshot build for CentOS 8:

> ../src/swift-DEVELOPMENT-SNAPSHOT-2021-07-07-a-centos8/usr/bin/swift build
/home/butta/swift-nio/Sources/_NIO1APIShims/NIO1APIShims.swift:49:1: error: type 'StaticString' does not conform to protocol 'Collection'
extension StaticString: Collection {
^
/home/butta/swift-nio/Sources/*NIO1APIShims/NIO1APIShims.swift:49:1: error: unavailable subscript 'subscript(*🙂' was used to satisfy a requirement of protocol 'Collection'
extension StaticString: Collection {
^
Swift.Collection:3:12: note: 'subscript(_🙂' declared here
public subscript(bounds: Range<Self.Index>) -> Self.SubSequence

{ get }
^
Swift.Collection:12:5: note: requirement 'subscript(_🙂' declared here
subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }

^

I figure this is related to this recent stdlib pull:

#38161

@glessard, let me know what you think. I filed a NIO issue too:

apple/swift-nio#1892

@typesanitizer
Copy link

@swift-ci create

@glessard
Copy link
Contributor

glessard commented Jul 9, 2021

apple/swift-nio#1893

@finagolfin
Copy link
Contributor Author

Thanks for fixing NIO. If this is going to need to be updated in other projects too, particularly since it was just added to Swift 5.5, maybe this breaking change and how to fix it should be publicly documented somewhere, though I'm unsure where that would be.

@glessard
Copy link
Contributor

I will see whether I can get an item added to release notes.
Note that I am interested in knowing whether what happened to NIO happens anywhere else.

The standard library bug that we fixed allowed incomplete Collection conformances to compile. NIO was the only project to hit this from the compatibility suite. There are 4 essential conditions for a project to stop compiling due to this:

  1. It needs to implement a new Collection,
  2. That Collection defines a non-default SubSequence (that is, it declares that it doesn't want to use Slice),
  3. That Collection does not define the slicing subscript (subscript(bounds: Range<Index>)),
  4. The slicing subscript is not used or tested.

The first 3 meant that another utility subscript<R: RangeExpression>(_ range: R) was inadvertently getting picked up to satisfy the requirement, and with those conditions combined it ended up calling itself, resulting in a stack overflow if called at runtime.

Item 4 is key: any use of that slicing subscript would have resulted in a crash. PR-38161 converted the latent bug to a compilation error.

@finagolfin
Copy link
Contributor Author

Alright, seems like a worthwhile change and if you think it's a rare issue, should be no problem.

theindigamer (JIRA User), please close if you're happy, I'm good.

@glessard
Copy link
Contributor

NIO has enacted an even better fix: removing the NIO1 API shims where this problem occurred. apple/swift-nio#1897

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants