Closed weissi closed 4 years ago
this was first reported as https://github.com/apple/swift-nio-ssl/issues/116
CC @Lukasa
@swift-ci create
The compiler shouldn't crash, but that looks like a real ambiguity to me?
Oh, I see. The ambiguity is in trying to figure out what the mangled name "typedef ECDSA_SIG from C" means, which is a true ambiguity…but shouldn't crash the compiler. I don't think anything changed here recently; it's just a comparison between a with-asserts and a no-asserts compiler. It's also unclear what should be done about this, since the typedefs really are incompatible and that means that you potentially won't be able to debug this program.
@belkadan So yes, the typedef ECDSA_SIG
will be present multiple times in the program but it should never be included into the same compilation unit. All the actual symbols at runtime will not be clashing because they're prefixed in CNIOBoringSSL
(something like CNIOBoringSSL_SSL_write
instead of SSL_write
). Also the header paths are also CNIOBoringSSL/bio.h
(instead of the usual ssl/bio.h
.
But I can see that it would be troublesome for a debugger to find the right decl but tbh if somebody needs to debug BoringSSL, they'll have a bad day anyway 😛
The compiler can still see them both because it has to resolve imports. Maybe implementation-only imports will be able to handle this at some point, though.
(To be clear, I definitely think this is a problem. I just don't know what to do about it.)
Thanks @belkadan, do we understand why it’s working on Swift 5.0.x then? Because it seems to be no problem there...
I suspect we just didn't have the assertion there, and it was just as broken. But you're right that I haven't confirmed that.
Added a much smaller repro (in clash-crash-repro.tar.gz
):
Pacakge.swift
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "adsf",
dependencies: [
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.systemLibrary(
name: "CAPNSOpenSSL",
pkgConfig: "openssl",
providers: [
.apt(["openssl libssl-dev"]),
.brew(["openssl"]),
]
),
.target(
name: "adsf",
dependencies: ["NIOSSL", "CAPNSOpenSSL"]),
.testTarget(
name: "adsfTests",
dependencies: ["adsf"]),
]
)
and main.swift
import NIOSSL
import CAPNSOpenSSL
let x: UnsafePointer<SHA256_CTX>? = nil
print(x ?? "all good")
@belkadan hmm, but before the crash (the assertion) we hit a compiler error, right? So even if the assertion were taken out, we'd still hit the compiler error which wasn't the case in 5.0.x.
I am 95% sure the compiler error is coming from work being done for the assertion, but we'll have to test that.
That makes sense! Thanks @belkadan
Looks like this has been fixed with recent compilers (the clash-crash-repro no longer crashes the compiler).
Attachment: Download
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: c3526df0957007fcac1ce3f6d9b8dbcbrelates to:
Issue Description:
The attached sample project (folder name
qwer
) compiled just fine with Swift 5.1 from Xcode 11, beta 3 (Apple Swift version 5.1 (swiftlang-1100.0.212.5 clang-1100.0.28.2)
) but throws ambiguity errors and crashes the compiler with the 12th July 2019 snapshot ({{Apple Swift version 5.1-dev (LLVM 688b71e2f9, Swift a062b3ca64) }}).The project can be described by this
Package.swift
:and this
main.swift
repro:
for APNSwift, you'll need to have openssl 1.1 installed (just run
brew install brew install openssl@1.1
before the repro instructions)errors are: