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

Assertion failure in importParameterType when importing getKnownFolderLocations on Xcode 16.2 #79636

Open
hamishknight opened this issue Feb 26, 2025 · 0 comments
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. clang importer Area → compiler: The clang importer crash Bug: A crash, i.e., an abnormal termination of software found by stress tester Flag: An issue found by the SourceKit stress tester

Comments

@hamishknight
Copy link
Contributor

hamishknight commented Feb 26, 2025

This hits an assertion in the Clang importer on Xcode 16.2 when building for iOS:

import FileProvider

func foo(_ x: AnyObject) {
  _ = x.getKnownFolderLocations
}
Assertion failed: (clangEnum.value() ->getIntegerType() ->getCanonicalTypeInternal() == typedefType->getCanonicalTypeInternal()), function importParameterType, file ImportType.cpp, line 2478.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-frontend -typecheck /Users/hamish/src/swift-test-arena/main.swift -sdk /Users/hamish/src/iPhoneOS.sdk -debug-diagnostic-names -diagnostic-style=llvm -target arm64-apple-ios16.0
1.      Swift version 6.2-dev (LLVM 5de518080964bf3, Swift c6d1060778f3563)
2.      Compiling with effective version 5.10
3.      While evaluating request TypeCheckPrimaryFileRequest(source_file "/Users/hamish/src/swift-test-arena/main.swift")
4.      While evaluating request TypeCheckFunctionBodyRequest(main.(file).foo@/Users/hamish/src/swift-test-arena/main.swift:819:6)
5.      While type-checking statement at [/Users/hamish/src/swift-test-arena/main.swift:819:26 - line:821:1] RangeText="{
  _ = x.getKnownFolderLocations
"
6.      While type-checking expression at [/Users/hamish/src/swift-test-arena/main.swift:820:3 - line:820:9] RangeText="_ = x."
7.      While type-checking-target starting at /Users/hamish/src/swift-test-arena/main.swift:820:3
8.      While evaluating request AnyObjectLookupRequest(0x11e5e7508 AbstractFunctionDecl name=foo(_:) : (AnyObject) -> (), 'getKnownFolderLocations', { NL_ProtocolMembers, NL_IgnoreMissingImports })
9.      /Users/hamish/src/iPhoneOS.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderKnownFolders.h:135:1: importing 'NSFileProviderKnownFolderSupporting::getKnownFolderLocations:completionHandler:'
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           0x0000000107f5aba4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000107f58ec0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000107f5b220 SignalHandler(int, __siginfo*, void*) + 324
3  libsystem_platform.dylib 0x00000001810b4184 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018107ef70 pthread_kill + 288
5  libsystem_c.dylib        0x0000000180f8b908 abort + 128
6  libsystem_c.dylib        0x0000000180f8ac1c err + 0
7  swift-frontend           0x0000000107fcebfc swift::ClangImporter::Implementation::inferDefaultArgument(clang::QualType, swift::OptionalTypeKind, swift::DeclBaseName, llvm::StringRef, bool, bool, swift::importer::NameImporter&) (.cold.10) + 0
8  swift-frontend           0x00000001036f2d10 swift::ClangImporter::Implementation::importParameterType(clang::ParmVarDecl const*, swift::OptionalTypeKind, bool, bool, bool, bool, std::__1::optional<unsigned int>, llvm::ArrayRef<swift::GenericTypeParamDecl*>, llvm::function_ref<void (swift::Diagnostic&&)>) + 1792
9  swift-frontend           0x00000001036f4980 swift::ClangImporter::Implementation::importMethodParamsAndReturnType(swift::DeclContext const*, clang::ObjCMethodDecl const*, llvm::ArrayRef<clang::ParmVarDecl const*>, bool, bool, swift::ParameterList**, swift::importer::ImportedName, std::__1::optional<swift::ForeignAsyncConvention>&, std::__1::optional<swift::ForeignErrorConvention>&, swift::SpecialMethodKind) + 2716
10 swift-frontend           0x00000001036c577c (anonymous namespace)::SwiftDeclConverter::importObjCMethodDecl(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, std::__1::optional<(anonymous namespace)::AccessorInfo>) + 2024
11 swift-frontend           0x00000001036c87f0 (anonymous namespace)::SwiftDeclConverter::VisitObjCMethodDecl(clang::ObjCMethodDecl const*) + 308
12 swift-frontend           0x00000001036bb238 swift::ClangImporter::Implementation::importDeclImpl(clang::NamedDecl const*, swift::importer::ImportNameVersion, bool&, bool&) + 816
13 swift-frontend           0x00000001036bc00c swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, swift::importer::ImportNameVersion, bool, bool) + 484
14 swift-frontend           0x000000010369adac bool llvm::function_ref<bool (swift::importer::ImportedName, swift::importer::ImportNameVersion)>::callback_fn<swift::ClangImporter::Implementation::lookupObjCMembers(swift::SwiftLookupTable&, swift::DeclName, swift::VisibleDeclConsumer&)::$_0>(long, swift::importer::ImportedName, swift::importer::ImportNameVersion) + 60
15 swift-frontend           0x00000001036ee0ac swift::importer::NameImporter::forEachDistinctImportName(clang::NamedDecl const*, swift::importer::ImportNameVersion, llvm::function_ref<bool (swift::importer::ImportedName, swift::importer::ImportNameVersion)>) + 248
16 swift-frontend           0x000000010366bae8 swift::ClangImporter::Implementation::lookupObjCMembers(swift::SwiftLookupTable&, swift::DeclName, swift::VisibleDeclConsumer&) + 252
17 swift-frontend           0x000000010366b978 swift::ClangModuleUnit::lookupClassMember(swift::ImportPath::Access, swift::DeclName, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 132
18 swift-frontend           0x0000000103a37cf4 swift::ModuleDecl::lookupClassMember(swift::ImportPath::Access, swift::DeclName, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 228
19 swift-frontend           0x0000000103a74ca4 swift::AnyObjectLookupRequest::evaluate(swift::Evaluator&, swift::DeclContext const*, swift::DeclNameRef, swift::NLOptions) const + 140
20 swift-frontend           0x0000000103a81124 swift::AnyObjectLookupRequest::OutputType swift::Evaluator::getResultUncached<swift::AnyObjectLookupRequest, swift::AnyObjectLookupRequest::OutputType swift::evaluateOrDefault<swift::AnyObjectLookupRequest>(swift::Evaluator&, swift::AnyObjectLookupRequest, swift::AnyObjectLookupRequest::OutputType)::'lambda'()>(swift::AnyObjectLookupRequest const&, swift::AnyObjectLookupRequest::OutputType swift::evaluateOrDefault<swift::AnyObjectLookupRequest>(swift::Evaluator&, swift::AnyObjectLookupRequest, swift::AnyObjectLookupRequest::OutputType)::'lambda'()) + 248
21 swift-frontend           0x0000000103a73cbc swift::AnyObjectLookupRequest::OutputType swift::evaluateOrDefault<swift::AnyObjectLookupRequest>(swift::Evaluator&, swift::AnyObjectLookupRequest, swift::AnyObjectLookupRequest::OutputType) + 160
22 swift-frontend           0x0000000103a73aec swift::DeclContext::lookupQualified(swift::Type, swift::DeclNameRef, swift::SourceLoc, swift::NLOptions, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 140
23 swift-frontend           0x00000001035c26a4 swift::TypeChecker::lookupMember(swift::DeclContext*, swift::Type, swift::DeclNameRef, swift::SourceLoc, swift::optionset::OptionSet<swift::NameLookupFlags, unsigned int>) + 300
24 swift-frontend           0x0000000103437e48 swift::constraints::ConstraintSystem::lookupMember(swift::Type, swift::DeclNameRef, swift::SourceLoc) + 172
25 swift-frontend           0x000000010338cae0 swift::constraints::ConstraintSystem::performMemberLookup(swift::constraints::ConstraintKind, swift::DeclNameRef, swift::Type, swift::FunctionRefInfo, swift::constraints::ConstraintLocator*, bool) + 2716
26 swift-frontend           0x000000010338f634 swift::constraints::ConstraintSystem::simplifyMemberConstraint(swift::constraints::ConstraintKind, swift::Type, swift::DeclNameRef, swift::Type, swift::DeclContext*, swift::FunctionRefInfo, llvm::ArrayRef<swift::constraints::OverloadChoice>, swift::optionset::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 1424
27 swift-frontend           0x00000001033639d8 swift::constraints::ConstraintSystem::addValueMemberConstraint(swift::Type, swift::DeclNameRef, swift::Type, swift::DeclContext*, swift::FunctionRefInfo, llvm::ArrayRef<swift::constraints::OverloadChoice>, swift::constraints::ConstraintLocatorBuilder) + 212
28 swift-frontend           0x000000010336539c (anonymous namespace)::ConstraintGenerator::addMemberRefConstraints(swift::Expr*, swift::Expr*, swift::DeclNameRef, swift::FunctionRefInfo, llvm::ArrayRef<swift::ValueDecl*>) + 656
29 swift-frontend           0x000000010335ec08 (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 15232
30 swift-frontend           0x00000001038a7908 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 988
31 swift-frontend           0x00000001038a8adc (anonymous namespace)::Traversal::visitAssignExpr(swift::AssignExpr*) + 60
32 swift-frontend           0x00000001038a7788 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 604
33 swift-frontend           0x00000001038a7520 swift::Expr::walk(swift::ASTWalker&) + 32
34 swift-frontend           0x0000000103357bf8 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*) + 164
35 swift-frontend           0x00000001033564a8 swift::constraints::ConstraintSystem::generateConstraints(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 508
36 swift-frontend           0x00000001033b2e24 swift::constraints::ConstraintSystem::solveImpl(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 392
37 swift-frontend           0x00000001033b2740 swift::constraints::ConstraintSystem::solve(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 144
38 swift-frontend           0x000000010353335c swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::DiagnosticTransaction*) + 284
39 swift-frontend           0x00000001035331e4 swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::DiagnosticTransaction*) + 196
40 swift-frontend           0x00000001035330ac swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 96
41 swift-frontend           0x00000001035f87c0 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 236
42 swift-frontend           0x00000001035fb9bc swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 136
43 swift-frontend           0x00000001035fa1f4 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
44 swift-frontend           0x00000001035f9b88 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 32
45 swift-frontend           0x00000001035f98e0 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1100
46 swift-frontend           0x00000001039a3520 swift::TypeCheckFunctionBodyRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()>(swift::TypeCheckFunctionBodyRequest const&, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()) + 224
47 swift-frontend           0x00000001039230a4 swift::AbstractFunctionDecl::getTypecheckedBody() const + 112
48 swift-frontend           0x0000000103a43418 swift::SourceFile::typeCheckDelayedFunctions() + 96
49 swift-frontend           0x000000010363f8e4 swift::TypeCheckPrimaryFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 228
50 swift-frontend           0x00000001036410b4 swift::TypeCheckPrimaryFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckPrimaryFileRequest, swift::TypeCheckPrimaryFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckPrimaryFileRequest>(swift::Evaluator&, swift::TypeCheckPrimaryFileRequest, swift::TypeCheckPrimaryFileRequest::OutputType)::'lambda'()>(swift::TypeCheckPrimaryFileRequest const&, swift::TypeCheckPrimaryFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckPrimaryFileRequest>(swift::Evaluator&, swift::TypeCheckPrimaryFileRequest, swift::TypeCheckPrimaryFileRequest::OutputType)::'lambda'()) + 216
51 swift-frontend           0x000000010363f7d8 swift::performTypeChecking(swift::SourceFile&) + 84
52 swift-frontend           0x0000000102690d58 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_0>(long, swift::SourceFile&) + 16
53 swift-frontend           0x00000001026882d4 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 164
54 swift-frontend           0x0000000102688210 swift::CompilerInstance::performSema() + 76
55 swift-frontend           0x000000010244b6bc withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
56 swift-frontend           0x0000000102441188 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 700
57 swift-frontend           0x00000001024409e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2208
58 swift-frontend           0x0000000102232fa8 swift::mainEntry(int, char const**) + 3052
59 dyld                     0x0000000180cfc274 start + 2840
fish: Job 1, './swift -frontend -typecheck ~/…' terminated by signal SIGABRT (Abort)

This was originally found by the stress tester for the following test case:

import FileProvider
let _ = Array()
// RUN: %sourcekitd-test -req=typecontextinfo -pos=%(line-1):15 main.swift -- main.swift -sdk $(xcrun -sdk iphoneos --show-sdk-path) -target arm64-apple-ios16.0
@hamishknight hamishknight added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. clang importer Area → compiler: The clang importer found by stress tester Flag: An issue found by the SourceKit stress tester crash Bug: A crash, i.e., an abnormal termination of software labels Feb 26, 2025
@hamishknight hamishknight changed the title Assertion failure in importParameterType for type context info SourceKit request on Xcode 16.2 Assertion failure in importParameterType when importing getKnownFolderLocations on Xcode 16.2 Feb 26, 2025
@hamishknight hamishknight added the assertion failure Bug → crash: An assertion failure label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. clang importer Area → compiler: The clang importer crash Bug: A crash, i.e., an abnormal termination of software found by stress tester Flag: An issue found by the SourceKit stress tester
Projects
None yet
Development

No branches or pull requests

1 participant