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

emitSILFunction crash when using typed throws on a @propertyWrapper method with nested error type #76317

Open
JadenGeller opened this issue Sep 6, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels

Comments

@JadenGeller
Copy link
Contributor

Description

The reproduction crashes the compiler unless either:
(a) throws(UnderflowError) is replaced with throws
(b) struct UnderflowError {} is unnested from the property wrapper namespace

Reproduction

@propertyWrapper
struct Stack<Value> {
    private var history: [Value]

    init(wrappedValue initialValue: Value) {
        self.history = [initialValue]
    }

    var wrappedValue: Value {
        get { history[history.endIndex - 1] }
        _modify { yield &history[history.endIndex - 1] }
        set { history[history.endIndex - 1] = newValue }
    }

    var projectedValue: Self {
        return self
    }

    mutating func push() {
        history.append(wrappedValue)
    }
    
    struct UnderflowError: Error { }

    mutating func pop() throws(UnderflowError) {
        guard history.count > 1 else { throw UnderflowError() }
        history.removeLast()
    }
}

Stack dump

0.	Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift-frontend -frontend -c -primary-file "Untitled 7.swift" -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -new-driver-path /Library/Developer/CommandLineTools/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Library/Developer/CommandLineTools/usr/lib/swift -module-name main -disable-clang-spi -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Library/Developer/Developer/usr/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -external-plugin-path /Library/Developer/Developer/usr/local/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -plugin-path /Library/Developer/CommandLineTools/usr/lib/swift/host/plugins -plugin-path /Library/Developer/CommandLineTools/usr/local/lib/swift/host/plugins -o "/var/folders/z7/v1gmxzg94ys8g2tdh5kdfhpm0000gn/T/TemporaryDirectory.QoT539/Untitled 7-1.o"
1.	Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
2.	Compiling with effective version 5.10
3.	While evaluating request IRGenRequest(IR Generation for file "Untitled 7.swift")
4.	While emitting IR SIL function "@$s4main5StackV3popyyAC14UnderflowErrorVyx_GYKF".
 for 'pop()' (at Untitled 7.swift:26:14)
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           0x000000010a8170fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010a815350 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010a8176c8 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x0000000194b94184 _sigtramp + 56
4  swift-frontend           0x00000001057ff254 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 6568
5  swift-frontend           0x00000001057ff254 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 6568
6  swift-frontend           0x00000001057fd408 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2088
7  swift-frontend           0x0000000105649098 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 3364
8  swift-frontend           0x00000001057b4c44 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4700
9  swift-frontend           0x00000001057fc954 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 176
10 swift-frontend           0x00000001057bdb3c swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 784
11 swift-frontend           0x00000001057b7574 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 180
12 swift-frontend           0x00000001051c685c generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
13 swift-frontend           0x00000001051c2088 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2176
14 swift-frontend           0x00000001051c0f74 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 984
15 swift-frontend           0x00000001051c4228 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1680
16 swift-frontend           0x00000001051c2f58 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3572
17 swift-frontend           0x000000010514a01c swift::mainEntry(int, char const**) + 3680
18 dyld                     0x00000001947dc274 start + 2840

Expected behavior

It should not crash.

Environment

Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0

Additional information

No response

@JadenGeller JadenGeller added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Sep 6, 2024
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. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant