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

Assertion failure in IRGen for reasync function usage #79465

Open
rintaro opened this issue Feb 18, 2025 · 0 comments
Open

Assertion failure in IRGen for reasync function usage #79465

rintaro opened this issue Feb 18, 2025 · 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

@rintaro
Copy link
Member

rintaro commented Feb 18, 2025

Description

Using reasync function in non-async function causes an assertion failure in IRGen

Reproduction

func reasyncFn(fn: () async -> Void) reasync {}
func test() {
  reasyncFn { _ = 1 }
}

Stack dump

% ../build/release/swift-macosx-arm64/bin/swift -frontend -emit-ir -enable-experimental-concurrency test.swift
Assertion failed: (isAsync()), function getAsyncContext, file GenCall.cpp, line 215.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/rintaro/Repositories/swift-oss/build/release/swift-macosx-arm64/bin/swift-frontend -emit-ir -enable-experimental-concurrency test.swift
1.	Swift version 6.2-dev (LLVM 23dd6ab259a178a, Swift f510342c8a9de12)
2.	Compiling with effective version 5.10
3.	While evaluating request IRGenRequest(IR Generation for module test)
4.	While emitting IR SIL function "@$s4testAAyyF".
 for 'test()' (at test.swift:2:1)
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           0x0000000105d2f02c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105d2d77c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105d2f674 SignalHandler(int, __siginfo*, void*) + 296
3  libsystem_platform.dylib 0x000000018efcae04 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018ef93f70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018eea0908 abort + 128
6  libsystem_c.dylib        0x000000018ee9fc1c err + 0
7  swift-frontend           0x0000000105d3e958 swift::irgen::ExplosionSchema::getScalarResultType(swift::irgen::IRGenModule&) const (.cold.3) + 0
8  swift-frontend           0x0000000100b761d8 (anonymous namespace)::AsyncCallEmission::setArgs(swift::irgen::Explosion&, bool, swift::irgen::WitnessMetadata*) + 1676
9  swift-frontend           0x0000000100d1f97c (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 3060
10 swift-frontend           0x0000000100d01cd8 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2188
11 swift-frontend           0x0000000100d004c4 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 8836
12 swift-frontend           0x0000000100cfdcc0 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1828
13 swift-frontend           0x0000000100baf598 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&) + 728
14 swift-frontend           0x0000000100cb5ca0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2376
15 swift-frontend           0x0000000100cfd250 swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 176
16 swift-frontend           0x0000000100cbd194 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'()) + 196
17 swift-frontend           0x0000000100cb6bfc swift::performIRGeneration(swift::ModuleDecl*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::GlobalVariable**) + 1356
18 swift-frontend           0x000000010083b5f8 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>>>) + 272
19 swift-frontend           0x00000001008382e0 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*) + 1332
20 swift-frontend           0x0000000100837abc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1312
21 swift-frontend           0x0000000100843970 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 164
22 swift-frontend           0x0000000100839400 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 700
23 swift-frontend           0x0000000100838c5c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2208
24 swift-frontend           0x000000010062afcc swift::mainEntry(int, char const**) + 3052
25 dyld                     0x000000018ec14274 start + 2840
zsh: abort      ../build/release/swift-macosx-arm64/bin/swift -frontend -emit-ir  test.swift

Expected behavior

Compiles without errors

Environment

main as of today

Additional information

No response

@rintaro rintaro 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 Feb 18, 2025
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