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-6648] A Compiler crash with optimization #49197

Closed
swift-ci opened this issue Dec 20, 2017 · 4 comments
Closed

[SR-6648] A Compiler crash with optimization #49197

swift-ci opened this issue Dec 20, 2017 · 4 comments
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 optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6648
Radar rdar://problem/36158103
Original Reporter linqingmo (JIRA User)
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, OptimizedOnly
Assignee shajrawi (JIRA)
Priority Medium

md5: 717c0ed83e3f2b6193c235f1d128d811

Issue Description:

extension Decodable {
    public static func decode(from data: Data) throws -> Self {
        let decoder = JSONDecoder()
        return try decoder.decode(self, from: data)
    }
}

public protocol TestDecodable: Decodable {}

public final class TestJSONDecoder: JSONDecoder {
    public override func decode<T: TestDecodable>(_ type: T.Type, from data: Data) throws -> T {
        return try super.decode(T.self, from: data)
    }
}

When compile with optimization, compiler will crash.

Assertion failed: (!substType->hasError() && "Error types should not appear in type-checked AST"), function getLoweredRValueType, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SIL/TypeLowering.cpp, line 1566.
0  swift                    0x00000001112d2718 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001112d1666 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x00000001112d2cde SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff553ccf5a _sigtramp + 26
4  libsystem_platform.dylib 0x00000000000034f0 _sigtramp + 2864932272
5  libsystem_c.dylib        0x00007fff551f7312 abort + 127
6  libsystem_c.dylib        0x00007fff551bf368 basename_r + 0
7  swift                    0x000000010eabe0a5 swift::Lowering::TypeConverter::getLoweredRValueType(swift::Lowering::AbstractionPattern, swift::CanType) + 3077
8  swift                    0x000000010eabd043 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 435
9  swift                    0x000000010ea180b6 (anonymous namespace)::SILTypeSubstituter::visitType(swift::CanType) + 310
10 swift                    0x000000010ea17a2f swift::CanType swift::CanTypeVisitor<(anonymous namespace)::SILTypeSubstituter, swift::CanType>::visit<>(swift::CanType) + 95
11 swift                    0x000000010ea124d1 (anonymous namespace)::SILTypeSubstituter::substSILFunctionType(swift::CanTypeWrapper<swift::SILFunctionType>) + 257
12 swift                    0x000000010ea12387 swift::SILFunctionType::substGenericArgs(swift::SILModule&, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) + 71
13 swift                    0x000000010ea122f8 swift::SILFunctionType::substGenericArgs(swift::SILModule&, swift::SubstitutionMap const&) + 56
14 swift                    0x000000010ea12246 swift::SILFunctionType::substGenericArgs(swift::SILModule&, llvm::ArrayRef<swift::Substitution>) + 54
15 swift                    0x000000010e66af5e swift::devirtualizeClassMethod(swift::FullApplySite, swift::SILValue, swift::OptRemark::Emitter*) + 1566
16 swift                    0x000000010e81c52f speculateMonomorphicTarget(swift::FullApplySite, swift::SILType, swift::CheckedCastBranchInst*&) + 2127
17 swift                    0x000000010e81ad0a (anonymous namespace)::SpeculativeDevirtualization::run() + 3114
18 swift                    0x000000010e6ee529 swift::SILPassManager::runPassOnFunction(swift::SILFunctionTransform*, swift::SILFunction*) + 4041
19 swift                    0x000000010e6ef6c4 swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>) + 1092
20 swift                    0x000000010e6f0b74 swift::SILPassManager::runOneIteration() + 964
21 swift                    0x000000010dfaabfb swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
22 swift                    0x000000010e6f93a5 swift::runSILOptimizationPasses(swift::SILModule&) + 117
23 swift                    0x000000010de58b7b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13723
24 swift                    0x000000010de545da swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3210
25 swift                    0x000000010de15470 main + 3360
26 libdyld.dylib            0x00007fff5514b115 start + 1

1.  While running pass #&#8203;6059 SILFunctionTransform "Speculative Devirtualization via Guarded Calls" on SILFunction "@_T0s9DecodableP7testPPPE6decodex10Foundation4DataV4from_tKFZ".
 for 'decode(from:)'
@belkadan
Copy link
Contributor

@eeckstein, who owns speculative devirtualization?

@eeckstein
Copy link
Member

Joe, can you please take a look?

@swift-ci
Copy link
Collaborator Author

Comment by Joe Shajrawi (JIRA)

@swift-ci create

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 1, 2019

Comment by Joe Shajrawi (JIRA)

Fixed in Swift 5

@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 optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

4 participants