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-10491] AST Verifier crash on IUO unwrap through AnyObject lookup #52891

Open
hamishknight opened this issue Apr 16, 2019 · 1 comment
Open
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 type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-10491
Radar rdar://problem/50169795
Original Reporter @hamishknight
Type Bug
Environment

Swift version 5.0-dev (LLVM 94d957ca75, Swift 130cd9e81f)
Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee None
Priority Medium

md5: ce4521d5f7dccd1e87ea948b15e07401

Issue Description:

The following crashes the AST verifier:

import Foundation

class C {
  @objc func foo() -> String! { return nil }
}

func bar(_ x: AnyObject) {
  let y: String = x.foo!()
}

Stack dump:

0.  Program arguments: ./swift -frontend -typecheck /Users/hamishknight/Desktop/Stochastic Projects/hang on a gosh darn sec/hang on a gosh darn sec/main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
1.  While walking into decl 'bar(_:)' (at /Users/hamishknight/Desktop/Stochastic Projects/hang on a gosh darn sec/hang on a gosh darn sec/main.swift:15:1)
2.  While walking into body of 'bar(_:)' (at /Users/hamishknight/Desktop/Stochastic Projects/hang on a gosh darn sec/hang on a gosh darn sec/main.swift:15:1)
3.  While walking into initializer for declaration 0x7fb5288cfb00 (at /Users/hamishknight/Desktop/Stochastic Projects/hang on a gosh darn sec/hang on a gosh darn sec/main.swift:16:3)
0  swift                    0x0000000112eaa585 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000112ea9588 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x0000000112eaab88 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff61b98b5d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 2655417536
5  swift                    0x000000010fe3d789 (anonymous namespace)::Verifier::checkSameType(swift::Type, swift::Type, char const*) + 41
6  swift                    0x000000010fe3f0e1 (anonymous namespace)::Verifier::checkOptionalObjectType(swift::Type, swift::Type, swift::Expr*) + 81
7  swift                    0x000000010fe332f8 (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 13656
8  swift                    0x000000010fe4657b (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 123
9  swift                    0x000000010fe487c0 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 752
10 swift                    0x000000010fe43af7 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 215
11 swift                    0x000000010fe468c8 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 472
12 swift                    0x000000010fe4983e (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 782
13 swift                    0x000000010fe43af7 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 215
14 swift                    0x000000010fe43a0b swift::Decl::walk(swift::ASTWalker&) + 27
15 swift                    0x000000010fef9f1a swift::SourceFile::walk(swift::ASTWalker&) + 170
16 swift                    0x000000010fe2ef4b swift::verify(swift::SourceFile&) + 59
17 swift                    0x000000010fbe6425 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1381
18 swift                    0x000000010f3708f6 swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 502
19 swift                    0x000000010f36f403 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 339
20 swift                    0x000000010f36ebf7 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 615
21 swift                    0x000000010f13c2dd performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1613
22 swift                    0x000000010f13ac36 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2982
23 swift                    0x000000010f0e1b08 main + 696
24 libdyld.dylib            0x00007fff619b33d5 start + 1
fish: './swift -frontend -typecheck /U…' terminated by signal SIGSEGV (Address boundary error)
@hamishknight
Copy link
Collaborator Author

Here's hoping we can deprecate AnyObject lookup soon

@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
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants