swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.59k stars 10.36k forks source link

[Source compatibility suite] Alamofire causing compiler crash #62841

Closed justice-adams-apple closed 1 year ago

justice-adams-apple commented 1 year ago

Describe the bug Alamofire is failing to build for 5.0 due to a compiler crash. The output seen is

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 269.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: swift-main-source-compat-suite/build/compat_macos/install/toolchain/usr/bin/swift-frontend -frontend -c /swift-source-compat-suite/project_cache/Alamofire/Source/NetworkReachabilityManager.swift /swift-source-compat-suite/project_cache/Alamofire/Source/ParameterEncoding.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Protector.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Response.swift /swift-source-compat-suite/project_cache/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /swift-source-compat-suite/project_cache/Alamofire/Source/RequestTaskMap.swift /swift-source-compat-suite/project_cache/Alamofire/Source/AFError.swift /swift-source-compat-suite/project_cache/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /swift-source-compat-suite/project_cache/Alamofire/Source/ParameterEncoder.swift /swift-source-compat-suite/project_cache/Alamofire/Source/OperationQueue+Alamofire.swift /swift-source-compat-suite/project_cache/Alamofire/Source/HTTPHeaders.swift /swift-source-compat-suite/project_cache/Alamofire/Source/HTTPMethod.swift /swift-source-compat-suite/project_cache/Alamofire/Source/RedirectHandler.swift /swift-source-compat-suite/project_cache/Alamofire/Source/ResponseSerialization.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Notifications.swift /swift-source-compat-suite/project_cache/Alamofire/Source/URLRequest+Alamofire.swift /swift-source-compat-suite/project_cache/Alamofire/Source/AFResult.swift /swift-source-compat-suite/project_cache/Alamofire/Source/RequestInterceptor.swift /swift-source-compat-suite/project_cache/Alamofire/Source/DispatchQueue+Alamofire.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Alamofire.swift /swift-source-compat-suite/project_cache/Alamofire/Source/MultipartUpload.swift /swift-source-compat-suite/project_cache/Alamofire/Source/CachedResponseHandler.swift /swift-source-compat-suite/project_cache/Alamofire/Source/SessionDelegate.swift /swift-source-compat-suite/project_cache/Alamofire/Source/MultipartFormData.swift /swift-source-compat-suite/project_cache/Alamofire/Source/RetryPolicy.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Request.swift /swift-source-compat-suite/project_cache/Alamofire/Source/ServerTrustEvaluation.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Session.swift /swift-source-compat-suite/project_cache/Alamofire/Source/Validation.swift /swift-source-compat-suite/project_cache/Alamofire/Source/EventMonitor.swift /swift-source-compat-suite/project_cache/Alamofire/Source/AlamofireExtended.swift -supplementary-output-file-map /var/folders/pf/p5g2vb2j0yx1x6vlmxdppc700000gn/T/TemporaryDirectory.yASzLT/supplementaryOutputs-1 -target armv7k-apple-watchos3.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS8.0.sdk -I /swift-source-compat-suite/project_cache/Alamofire/build/Build/Products/Release-watchos -F /swift-source-compat-suite/project_cache/Alamofire/build/Build/Products/Release-watchos -application-extension -g -import-underlying-module -module-cache-path /swift-source-compat-suite/project_cache/Alamofire/build/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -O -new-driver-path swift-main-source-compat-suite/build/compat_macos/install/toolchain/usr/bin/swift-driver -serialize-debugging-options -empty-abi-descriptor -resource-dir swift-main-source-compat-suite/build/compat_macos/install/toolchain/usr/lib/swift -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/swift-overrides.hmap" -Xcc -iquote -Xcc "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Alamofire-generated-files.hmap" -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Alamofire-own-target-headers.hmap" -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Alamofire-all-non-framework-target-headers.hmap" -Xcc -ivfsoverlay -Xcc "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/all-product-headers.yaml" -Xcc -iquote -Xcc "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Alamofire-project-headers.hmap" -Xcc -I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Products/Release-watchos/include -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/DerivedSources-normal/armv7k" -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/DerivedSources/armv7k" -Xcc "-I/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/DerivedSources" -Xcc -ivfsoverlay -Xcc "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/unextended-module-overlay.yaml" -Xcc -working-directory/swift-source-compat-suite/project_cache/Alamofire -module-name Alamofire -target-sdk-version 8.0 -target-sdk-name watchos8.0 -enable-default-cmo -num-threads 12 -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/NetworkReachabilityManager.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/ParameterEncoding.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Protector.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Response.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/URLConvertible+URLRequestConvertible.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/RequestTaskMap.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/AFError.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/URLSessionConfiguration+Alamofire.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/ParameterEncoder.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/OperationQueue+Alamofire.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/HTTPHeaders.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/HTTPMethod.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/RedirectHandler.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/ResponseSerialization.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Notifications.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/URLRequest+Alamofire.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/AFResult.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/RequestInterceptor.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/DispatchQueue+Alamofire.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Alamofire.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/MultipartUpload.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/CachedResponseHandler.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/SessionDelegate.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/MultipartFormData.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/RetryPolicy.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Request.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/ServerTrustEvaluation.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Session.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/Validation.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/EventMonitor.o" -o "/swift-source-compat-suite/project_cache/Alamofire/build/Build/Intermediates.noindex/Alamofire.build/Release-watchos/Alamofire watchOS.build/Objects-normal/armv7k/AlamofireExtended.o"
1.  Apple Swift version 5.8-dev (LLVM ab856b0fa3177ee, Swift 60952b868d46fc9)
2.  Compiling with the current language version
3.  While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Alamofire)
4.  While running pass #942997 SILFunctionTransform "Mem2Reg" on SILFunction "@$sSayxG9Alamofire0A8ExtendedA2bCP2afAB0A9ExtensionVy0B4TypeQzGvMTW".
 for modify for af (at /swift-source-compat-suite/project_cache/Alamofire/Source/AlamofireExtended.swift:54:9)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010f9c4647 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010f9c3578 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010f9c4ca0 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007fff20391d7d _sigtramp + 29
4  swift-frontend           0x00000001125c1000 llvm::CSR_Altivec_SaveList + 342816
5  libsystem_c.dylib        0x00007fff202a1406 abort + 125
6  libsystem_c.dylib        0x00007fff202a07d8 err + 0
7  swift-frontend           0x000000010fdc32b3 swift::CanTypeWrapperTraits<swift::TupleType>::type swift::SILType::castTo<swift::TupleType>() const (.cold.3) + 35
8  swift-frontend           0x000000010b20bd8a swift::CanTypeWrapperTraits<swift::TupleType>::type swift::SILType::castTo<swift::TupleType>() const + 90
9  swift-frontend           0x000000010ad95848 createValueForEmptyTuple(swift::SILType, swift::SILInstruction*, swift::SILBuilderContext&) + 40
10 swift-frontend           0x000000010ad93339 (anonymous namespace)::MemoryToRegisters::promoteSingleAllocation(swift::AllocStackInst*) + 1881
11 swift-frontend           0x000000010ad929e6 (anonymous namespace)::SILMem2Reg::run() + 838
12 swift-frontend           0x000000010ac88b6e swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 2526
13 swift-frontend           0x000000010ac8992a swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1402
14 swift-frontend           0x000000010ac86b28 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
15 swift-frontend           0x000000010ac86ac3 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 51
16 swift-frontend           0x000000010acaccad swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
17 swift-frontend           0x000000010ac930c1 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 241
18 swift-frontend           0x000000010ac86d54 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 68
19 swift-frontend           0x000000010ac97737 swift::runSILOptimizationPasses(swift::SILModule&) + 151
20 swift-frontend           0x000000010a5824d3 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 595
21 swift-frontend           0x000000010a3ee44c performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 668
22 swift-frontend           0x000000010a3ee029 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2313
23 swift-frontend           0x000000010a3efd6a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3962
24 swift-frontend           0x000000010a221c24 swift::mainEntry(int, char const**) + 1204
25 libdyld.dylib            0x00007fff20367f3d start + 1
26 libdyld.dylib            0x00000000000000a3 start + 18446603339975721319
error: Abort trap: 6 (in target 'Alamofire watchOS' from project 'Alamofire')

This issue first occurred during the nightly run on Dec 22nd. When comparing https://www.swift.org/download/ nightly snapshots from

Steps To Reproduce Steps to reproduce the behavior: 1.) Download the Dec 29th toolchain from the swift.org download link above 2.) Clone https://github.com/Alamofire/Alamofire and checkout 576437d07f1c7f6db5a848fb3ee6bacc6bcdba24 3.) Run

<PATH-TO-swift-DEVELOPMENT-SNAPSHOT-2022-12-29-a.xctoolchain>/usr/bin/swift build --disable-sandbox --package-path <PATH_TO_SWIFT_NIO_EXTRAS> --verbose --configuration release --build-tests -Xswiftc -swift-version -Xswiftc 5 -Xswiftc -disallow-use-new-driver -Xswiftc -enable-testing

...

Expected behavior Expect the project to build correctly

Environment (please fill out the following information) https://ci.swift.org/job/swift-main-source-compat-suite/289

Additional context Apple Swift version 5.8-dev (LLVM ab856b0fa3177ee, Swift 60952b868d46fc9)

justice-adams-apple commented 1 year ago

This was fixed with https://github.com/apple/swift/pull/62864