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-9169] @autoclosure labelled enum case crashes #51662

Closed
hamishknight opened this issue Nov 2, 2018 · 7 comments
Closed

[SR-9169] @autoclosure labelled enum case crashes #51662

hamishknight opened this issue Nov 2, 2018 · 7 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 regression swift 5.0

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-9169
Radar rdar://problem/45962425
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 4.2-dev (LLVM b70847456e, Clang 86404441b8, Swift 96b8cc5335)
Target: x86_64-apple-darwin17.7.0

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

md5: e4e4b0055282874f63ef369ea7171649

Issue Description:

The following crashes:

enum E {
  case foo(x: @autoclosure () -> String)
}

It trips an assertion in IRGen:

Assertion failed: (flags.isNone()), function appendTypeList, file /Users/Hamish/Desktop/swift-dev/swift/lib/AST/ASTMangler.cpp, line 1763.
Stack dump:
0.  Program arguments: ./swift -frontend -c /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift
1.  While emitting IR for source file /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift
2.  While emitting field type metadata 'E' at /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:314:1
0  swift                    0x000000010c39f5a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010c39e578 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x000000010c39fbc2 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff77ab0f5a _sigtramp + 26
4  swift                    0x000000010d5065c8 cmark_strbuf__initbuf + 126531
5  libsystem_c.dylib        0x00007fff7784e1ae abort + 127
6  libsystem_c.dylib        0x00007fff778161ac basename_r + 0
7  swift                    0x0000000109027ff8 swift::Mangle::ASTMangler::appendTypeList(swift::Type) + 520
8  swift                    0x0000000109023dc9 swift::Mangle::ASTMangler::appendType(swift::Type) + 697
9  swift                    0x000000010842f5ca swift::irgen::IRGenMangler::withSymbolicReferences(swift::irgen::IRGenModule&, llvm::function_ref<void ()>) + 234
10 swift                    0x000000010842f6ec swift::irgen::IRGenMangler::mangleTypeForReflection(swift::irgen::IRGenModule&, swift::Type) + 44
11 swift                    0x00000001083e1be8 swift::irgen::IRGenModule::getTypeRef(swift::CanType, swift::irgen::MangledTypeRefRole) + 472
12 swift                    0x00000001083e72d5 FieldTypeMetadataBuilder::addFieldDecl(swift::ValueDecl const*, swift::CanType, bool) + 133
13 swift                    0x00000001083e7077 FieldTypeMetadataBuilder::layoutEnum() + 567
14 swift                    0x00000001083e6a03 FieldTypeMetadataBuilder::layout() + 339
15 swift                    0x00000001083e4649 ReflectionMetadataBuilder::emit(llvm::Optional<llvm::function_ref<llvm::Constant* (swift::irgen::IRGenModule&, swift::irgen::ConstantInit)> >, char const*) + 25
16 swift                    0x00000001083e421b FieldTypeMetadataBuilder::emit() + 267
17 swift                    0x00000001083e3e4c swift::irgen::IRGenModule::emitFieldMetadataRecord(swift::NominalTypeDecl const*) + 284
18 swift                    0x000000010835ca89 swift::irgen::IRGenModule::emitEnumDecl(swift::EnumDecl*) + 105
19 swift                    0x00000001083462db swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&) + 107
20 swift                    0x00000001084194d4 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1220
21 swift                    0x0000000108417f6e swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 734
22 swift                    0x000000010829d371 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 11905
23 swift                    0x0000000108299363 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3603
24 swift                    0x0000000108242aae main + 686
25 libdyld.dylib            0x00007fff777a2015 start + 1
fish: './swift -frontend -c /Users/Ham…' terminated by signal SIGABRT (Abort)
@hamishknight
Copy link
Collaborator Author

cc. @slavapestov – looks like autoclosure needs the same exclusion as escaping from the assertion added in https://github.com/apple/swift/pull/18693/files#diff-480e53bf3609acd27b15b5b44ccea14bR1752.

@slavapestov
Copy link
Member

I wonder if we should change the mangling to treat enum payloads as a parameter list and not a single tuple value. We eventually want to be able to put varargs in there too.

@slavapestov
Copy link
Member

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Nov 5, 2018

We eventually want to be able to put varargs in there too.

We do? That's not part of SE-0155.

@slavapestov
Copy link
Member

> We do? That's not part of SE-0155.

We don't ban it either, and if you define an enum case with a vararg we crash in SILGen. I don't think it would be difficult to get it working, but we should discuss this at some point if/when we get a full implementation of SE-0155.

@slavapestov
Copy link
Member

This fixes the autoclosure crash: #20626

@hamishknight
Copy link
Collaborator Author

Thanks Slava!

@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 regression swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants