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-15497] Compiler crash in swift::diagnoseUnownedImmediateDeallocation #57802

Closed
ahoppen opened this issue Nov 19, 2021 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself 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

@ahoppen
Copy link
Contributor

ahoppen commented Nov 19, 2021

Previous ID SR-15497
Radar rdar://85602946
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, FoundByStressTester
Assignee None
Priority Medium

md5: 8df6b97f73b8da662603690df70d5bdd

Issue Description:

Type checking the following code crashes due to a nullptr dereference. Removing the () after @UserDefault resolves the crash.

// RUN: %swift-frontend -typecheck  %s

public struct {
    @UserDefault()
    public static var region: String
}

@propertyWrapper
public struct UserDefault {
    init() {}
    public var wrappedValue: String
}

Stack trace

Stack dump:
0.  Program arguments: /Users/alex/swift-src/mbuild/Release+Asserts/swift-macosx-x86_64/bin/swift-frontend -module-cache-path /Users/alex/swift-src/mbuild/Release+Asserts/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -disable-objc-attr-requires-foundation-module -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999-frontend" -typecheck /Users/alex/swift-src/swift/test/SourceKit/test.swift
1.  Swift version 5.6-dev (LLVM b9226b08fee13e8, Swift 237338b5046a764)
2.  Compiling with effective version 4.1.50
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/alex/swift-src/swift/test/SourceKit/test.swift")
4.  While type-checking statement at [/Users/alex/swift-src/swift/test/SourceKit/test.swift:3:15 - line:6:1] RangeText="{
    @UserDefault()
    public static var region: String
"
5.  While type-checking expression at [/Users/alex/swift-src/swift/test/SourceKit/test.swift:3:15 - line:6:1] RangeText="{
    @UserDefault()
    public static var region: String
"
6.  While type-checking declaration 0x7fdf288222c8 (at /Users/alex/swift-src/swift/test/SourceKit/test.swift:5:19)
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           0x000000010a699b17 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010a698a38 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010a69a160 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007ff80abece2d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603370400657904
5  swift-frontend           0x000000010523f357 swift::diagnoseUnownedImmediateDeallocation(swift::ASTContext&, swift::Pattern const*, swift::SourceLoc, swift::Expr const*) + 279
6  swift-frontend           0x00000001053407d9 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 2921
7  swift-frontend           0x000000010533bed4 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 228
8  swift-frontend           0x000000010533bdd4 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 116
9  swift-frontend           0x00000001050a81f7 (anonymous namespace)::ClosureConstraintApplication::visitDecl(swift::Decl*) + 215
10 swift-frontend           0x00000001050a4412 swift::ASTVisitor<(anonymous namespace)::ClosureConstraintApplication, void, swift::ASTNode, void, void, void, void>::visit(swift::Stmt*) + 930
11 swift-frontend           0x00000001050a4012 swift::constraints::ConstraintSystem::applySolutionToBody(swift::constraints::Solution&, swift::ClosureExpr*, swift::DeclContext*&, std::__1::function<llvm::Optional<swift::constraints::SolutionApplicationTarget> (swift::constraints::SolutionApplicationTarget)>) + 354
12 swift-frontend           0x00000001050ae4ee swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SolutionApplicationTarget) + 718
13 swift-frontend           0x00000001052dd63f swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 543
14 swift-frontend           0x00000001052dd39e swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 78
15 swift-frontend           0x000000010540e6f5 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 229
16 swift-frontend           0x00000001054106dc swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 124
17 swift-frontend           0x000000010540f933 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 131
18 swift-frontend           0x000000010540f9c2 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 50
19 swift-frontend           0x0000000105456481 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 225
20 swift-frontend           0x0000000105457df0 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 416
21 swift-frontend           0x0000000105457ba4 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 100
22 swift-frontend           0x00000001054562af swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 31
23 swift-frontend           0x00000001042539de swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 158
24 swift-frontend           0x000000010425388a swift::CompilerInstance::performSema() + 74
25 swift-frontend           0x000000010406a031 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4753
26 swift-frontend           0x000000010401a247 swift::mainEntry(int, char const**) + 503
27 dyld                     0x00000001167634fe start + 462
/Users/alex/swift-src/mbuild/Release+Asserts/swift-macosx-x86_64/test-macosx-x86_64/SourceKit/Output/test.swift.script: line 1: 30063 Segmentation fault: 11  '/Users/alex/swift-src/mbuild/Release+Asserts/swift-macosx-x86_64/bin/swift-frontend' -module-cache-path /Users/alex/swift-src/mbuild/Release+Asserts/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -disable-objc-attr-requires-foundation-module -swift-version 4 -define-availability 'SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -define-availability 'SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2' -define-availability 'SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0' -define-availability 'SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4' -define-availability 'SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0' -define-availability 'SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5' -define-availability 'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0' -define-availability 'SwiftStdlib 5.6:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999'-frontend -typecheck /Users/alex/swift-src/swift/test/SourceKit/test.swift
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 11, 2022

Stopped occurring in the stress tester. Adding the test case to the test suite here: #42295

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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. compiler The Swift compiler in itself 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

2 participants