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

SILGen crash on using member type accessed through metatype value #73251

Open
AnthonyLatsis opened this issue Apr 25, 2024 · 0 comments
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 expressions Feature: expressions metatypes Feature → types: Metatypes nested types Feature: nested types SILGen Area → compiler: The SIL generation stage swift 6.0 types Feature: types

Comments

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Apr 25, 2024

Description

No response

Reproduction

struct Outer {
  struct Inner {}
}
let meta: Outer.Type
let _ = meta.Inner.self

This bug is not specific to .self. Any expression that compiles with an Outer.Inner base seems to do.

Stack dump

Assertion failed: (!E->getType()->is<LValueType>() && !E->getType()->is<InOutType>() && "RValueEmitter shouldn't be called on lvalues"), function visit, file SILGenExpr.cpp, line 432.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: bin/swift-frontend -debug-diagnostic-names -diagnostic-style=llvm -emit-sil /Users/mac/Desktop/test.swift
1.	Swift version 6.0-dev (LLVM beb75c68bf9e0fb, Swift eb40cc56777bae4)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
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           0x000000010d9447e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010d942c35 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010d944e3e SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff8058ea37d _sigtramp + 29
4  libsystem_platform.dylib 0x00006000011d4000 _sigtramp + 18446708923622661280
5  libsystem_c.dylib        0x00007ff8057dba4d abort + 126
6  libsystem_c.dylib        0x00007ff8057dad60 err + 0
7  swift-frontend           0x000000010600dccc (anonymous namespace)::RValueEmitter::visit(swift::Expr*) + 204
8  swift-frontend           0x0000000105ffbeb2 (anonymous namespace)::RValueEmitter::visitDotSyntaxBaseIgnoredExpr(swift::DotSyntaxBaseIgnoredExpr*, swift::Lowering::SGFContext) + 82
9  swift-frontend           0x0000000105feb64d swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 829
10 swift-frontend           0x000000010600e03e swift::Lowering::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, swift::Lowering::SGFContext>::visitIdentityExpr(swift::IdentityExpr*, swift::Lowering::SGFContext) + 94
11 swift-frontend           0x0000000105ffcb56 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitDotSelfExpr(swift::DotSelfExpr*, swift::Lowering::SGFContext) + 70
12 swift-frontend           0x0000000105feb899 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 1417
13 swift-frontend           0x0000000105fdbd11 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 209
14 swift-frontend           0x0000000105fdbb15 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, std::__1::optional<swift::SILLocation>) + 357
15 swift-frontend           0x0000000105fa694f swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool)::$_0::operator()(swift::Expr*, swift::VarDecl*, bool, std::__1::unique_ptr<swift::Lowering::Initialization, std::__1::default_delete<swift::Lowering::Initialization>>&) const + 671
16 swift-frontend           0x0000000105fa6331 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 1489
17 swift-frontend           0x0000000105fa6a26 swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*, bool) + 150
18 swift-frontend           0x0000000105fbb7b2 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 1522
19 swift-frontend           0x0000000106151e6a swift::Lowering::SILGenTopLevel::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 714
20 swift-frontend           0x000000010615167f swift::ASTVisitor<swift::Lowering::SILGenTopLevel, void, void, void, void, void, void>::visit(swift::Decl*) + 1391
21 swift-frontend           0x000000010614ee0d swift::Lowering::SILGenTopLevel::visitSourceFile(swift::SourceFile*) + 189
22 swift-frontend           0x000000010614e1e3 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*, swift::SILFunction*) + 1763
23 swift-frontend           0x0000000106150e2c swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*) + 316
24 swift-frontend           0x0000000105ec6ccb (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 91
25 swift-frontend           0x0000000105ec696f swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 879
26 swift-frontend           0x000000010612e5de std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 142
27 swift-frontend           0x000000010612e4f8 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 40
28 swift-frontend           0x0000000105ee2b18 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 264
29 swift-frontend           0x0000000105ee29f8 swift::ASTLoweringRequest::OutputType swift::Evaluator::operator()<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'(), (void*)0>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 40
30 swift-frontend           0x0000000105ec7584 swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest) + 36
31 swift-frontend           0x0000000105ec74a0 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 256
32 swift-frontend           0x00000001050ff5bb swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 283
33 swift-frontend           0x0000000105130d83 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29::operator()(swift::CompilerInstance&) const + 147
34 swift-frontend           0x0000000105130cdd bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29>(long, swift::CompilerInstance&) + 29
35 swift-frontend           0x00000001051300a1 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 33
36 swift-frontend           0x000000010512f038 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 392
37 swift-frontend           0x0000000105127555 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1349
38 swift-frontend           0x0000000105102a66 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 262
39 swift-frontend           0x000000010510144a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2794
40 swift-frontend           0x0000000104faf7ea run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 2410
41 swift-frontend           0x0000000104fae427 swift::mainEntry(int, char const**) + 1543
42 swift-frontend           0x0000000104fad952 main + 34
43 dyld                     0x00007ff8055343a6 start + 1942
Abort trap: 6

Expected behavior

Successful compilation.

Environment

Swift version 6.0-dev (LLVM beb75c68bf9e0fb, Swift eb40cc5)
Target: x86_64-apple-macosx14.0

Additional information

No response

@AnthonyLatsis AnthonyLatsis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself SILGen Area → compiler: The SIL generation stage crash Bug: A crash, i.e., an abnormal termination of software metatypes Feature → types: Metatypes nested types Feature: nested types expressions Feature: expressions types Feature: types swift 6.0 labels Apr 25, 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. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software expressions Feature: expressions metatypes Feature → types: Metatypes nested types Feature: nested types SILGen Area → compiler: The SIL generation stage swift 6.0 types Feature: types
Projects
None yet
Development

No branches or pull requests

1 participant