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-14864] Segmentation fault compiling async code #57211

Closed
NachoSoto opened this issue Jul 1, 2021 · 3 comments
Closed

[SR-14864] Segmentation fault compiling async code #57211

NachoSoto opened this issue Jul 1, 2021 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself concurrency Feature: umbrella label for concurrency language features

Comments

@NachoSoto
Copy link
Contributor

NachoSoto commented Jul 1, 2021

Previous ID SR-14864
Radar rdar://problem/80043610
Original Reporter @NachoSoto
Type Bug
Environment

Seg

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

md5: 24caf23aba0e1e062be6c0ed440d0cab

Issue Description:

Code:

let url = "https://google.com"
                
async let data = URLSession.shared.data(from: URL(string: url)!)
async let response = try? (data.1 as? HTTPURLResponse)
                
print(await response?.statusCode)

Error:

1.  Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/nachosoto/dev/tests/LocalizedNames/LocalizedNames/ContentView.swift")
3.  While silgen emitFunction SIL function "@$s14LocalizedNames11ContentViewV4bodyQrvg".
 for getter for body (at /Users/nachosoto/dev/tests/LocalizedNames/LocalizedNames/ContentView.swift:11:9)
4.  While silgen closureexpr SIL function "@$s14LocalizedNames11ContentViewV4bodyQrvgyyYacfU_".
 for expression at [/Users/nachosoto/dev/tests/LocalizedNames/LocalizedNames/ContentView.swift:14:19 - line:22:13] RangeText="{
                let url = "https://google.com"
                
                async let data = URLSession.shared.data(from: URL(string: url)!)
                async let response = try? (data.1 as? HTTPURLResponse)
                
                print(await response?.statusCode)
            "
5.  While silgen closureexpr SIL function "@$s14LocalizedNames11ContentViewV4bodyQrvgyyYacfU_So17NSHTTPURLResponseCSgyYaYbcfu0_".
 for expression at [/Users/nachosoto/dev/tests/LocalizedNames/LocalizedNames/ContentView.swift:19:38 - line:19:70] RangeText="try? (data.1 as? HTTPURLResponse"
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           0x000000010c3320a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010c331038 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010c3326b6 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff2060bd7d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000007f96 _sigtramp + 18446603339972985398
5  swift-frontend           0x0000000107b364d5 swift::SILBuilder::createApply(swift::SILLocation, swift::SILValue, swift::SubstitutionMap, llvm::ArrayRef<swift::SILValue>, swift::OptionSet<swift::ApplyFlags, unsigned char>, swift::GenericSpecializationInformation const*) + 165
6  swift-frontend           0x0000000107b20ed2 emitRawApply(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::OptionSet<swift::ApplyFlags, unsigned char>, llvm::ArrayRef<swift::SILValue>, llvm::SmallVectorImpl<swift::SILValue>&, swift::Lowering::ExecutorBreadcrumb) + 1474
7  swift-frontend           0x0000000107b21609 swift::Lowering::SILGenFunction::emitApply(std::__1::unique_ptr<swift::Lowering::ResultPlan, std::__1::default_delete<swift::Lowering::ResultPlan> >&&, swift::Lowering::ArgumentScope&&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::CalleeTypeInfo const&, swift::OptionSet<swift::ApplyFlags, unsigned char>, swift::Lowering::SGFContext, llvm::Optional<swift::ActorIsolation>) + 921
8  swift-frontend           0x0000000107b29717 swift::Lowering::SILGenFunction::emitApplyOfLibraryIntrinsic(swift::SILLocation, swift::FuncDecl*, swift::SubstitutionMap, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::SGFContext) + 1175
9  swift-frontend           0x0000000107b339eb swift::Lowering::SILGenFunction::completeAsyncLetChildTask(swift::PatternBindingDecl*, unsigned int) + 475
10 swift-frontend           0x0000000107bbf046 swift::Lowering::SILGenFunction::maybeEmitValueOfLocalVarDecl(swift::VarDecl*, swift::AccessKind) + 454
11 swift-frontend           0x0000000107bbf124 swift::Lowering::SILGenFunction::emitRValueForNonMemberVarDecl(swift::SILLocation, swift::ConcreteDeclRef, swift::CanType, swift::AccessSemantics, swift::Lowering::SGFContext) + 164
12 swift-frontend           0x0000000107b80a3f swift::Lowering::SILGenFunction::emitRValueForDecl(swift::SILLocation, swift::ConcreteDeclRef, swift::Type, swift::AccessSemantics, swift::Lowering::SGFContext) + 527
13 swift-frontend           0x0000000107b909b2 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 6834
14 swift-frontend           0x0000000107b90b6d swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 7277
15 swift-frontend           0x0000000107ba016a swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 70250
16 swift-frontend           0x0000000107b8ef48 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 72
17 swift-frontend           0x0000000107b953bc swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 25788
18 swift-frontend           0x0000000107c061b2 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 450
19 swift-frontend           0x0000000107baf0c1 swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 737
20 swift-frontend           0x0000000107b1272b swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 1947
21 swift-frontend           0x0000000107ba34a0 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 240
22 swift-frontend           0x0000000107b8ef8f swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 143
23 swift-frontend           0x0000000107b71e03 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 371
24 swift-frontend           0x0000000107b1873d swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 125
25 swift-frontend           0x0000000107bfde4c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 460
26 swift-frontend           0x0000000107baf07b swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 667
27 swift-frontend           0x0000000107b1272b swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 1947
28 swift-frontend           0x0000000107ba34a0 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 240
29 swift-frontend           0x0000000107b8ef8f swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 143
30 swift-frontend           0x0000000107b82c08 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 40
31 swift-frontend           0x0000000107b3749e (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 3710
32 swift-frontend           0x0000000107b232b9 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 169
33 swift-frontend           0x0000000107b3f483 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, swift::Lowering::CalleeTypeInfo::ForeignInfo const&) && + 675
34 swift-frontend           0x0000000107b3ef2c (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::Lowering::CalleeTypeInfo::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&) + 1276
35 swift-frontend           0x0000000107b283b9 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2537
36 swift-frontend           0x0000000107b26176 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2694
37 swift-frontend           0x0000000107b8ef5f swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 95
38 swift-frontend           0x0000000107b7fec6 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 118
39 swift-frontend           0x0000000107b7263c swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 2476
40 swift-frontend           0x0000000107b1873d swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 125
41 swift-frontend           0x0000000107bfde4c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 460
42 swift-frontend           0x0000000107bade28 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 776
43 swift-frontend           0x0000000107b144df swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 9551
44 swift-frontend           0x0000000107b16998 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef, bool) + 376
45 swift-frontend           0x0000000107b11f78 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 216
46 swift-frontend           0x0000000107c1365d void llvm::function_ref<void (swift::AccessorDecl*)>::callback_fn<(anonymous namespace)::SILGenType::visitAccessors(swift::AbstractStorageDecl*)::'lambda'(swift::AccessorDecl*)>(long, swift::AccessorDecl*) + 29
47 swift-frontend           0x000000010869f6aa swift::AbstractStorageDecl::visitEmittedAccessors(llvm::function_ref<void (swift::AccessorDecl*)>) const + 90
48 swift-frontend           0x0000000107c135f0 (anonymous namespace)::SILGenType::visitVarDecl(swift::VarDecl*) + 416
49 swift-frontend           0x0000000107c0e90b (anonymous namespace)::SILGenType::emitType() + 411
50 swift-frontend           0x0000000107b1bcf1 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 97
51 swift-frontend           0x0000000107b197cc swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 4124
52 swift-frontend           0x0000000107bfd875 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&) + 197
53 swift-frontend           0x0000000107b1e77c llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 652
54 swift-frontend           0x000000010745bf68 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 13144
55 swift-frontend           0x000000010739dd98 main + 1032
56 libdyld.dylib            0x00007fff205e1f5d start + 1
@typesanitizer
Copy link

Crashes on main, thanks for the minimal example.

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@hborla
Copy link
Member

hborla commented Jan 23, 2024

The crash is resolved in Swift 5.10. The issue is capturing an async let variable in another async let:

error: capturing 'async let' variables is not supported
async let response = try? (data.1 as? HTTPURLResponse)
                           ^

@hborla hborla closed this as completed Jan 23, 2024
@NachoSoto
Copy link
Contributor Author

Awesome thanks!

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 concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

No branches or pull requests

3 participants