Skip to content

"SIL memory lifetime failure" when attempting to build Distributed Actors example. #62898

@fibrechannelscsi

Description

@fibrechannelscsi

Description
When attempting to run an example from the Distributed Actors repository (https://github.com/apple/swift-distributed-actors/), the compilation process encounters an error:

SIL memory lifetime failure in @$s18DistributedCluster0B16EventStreamActorC11actorSystemAcA0bG0C_tcfc: memory is initialized, but shouldn't be
memory location:   %40 = alloc_stack $ClusterSystem.ActorID        // users: %51, %50, %45
at instruction:   dealloc_stack %40 : $*ClusterSystem.ActorID     // id: %51

Further down, the additional error information is reported:

1.	Apple Swift version 5.8-dev (LLVM ed4d811c2897d77, Swift 8491f52d478aca6)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module DistributedCluster)
4.	While silgen constructor initializer SIL function "@$s18DistributedCluster0B16EventStreamActorC11actorSystemAcA0bG0C_tcfc".
 for 'init(actorSystem:)' (at /Users/username/distActors/Sources/DistributedCluster/Cluster/ClusterEventStream.swift:152:14)
5.	While verifying SIL function "@$s18DistributedCluster0B16EventStreamActorC11actorSystemAcA0bG0C_tcfc".
 for 'init(actorSystem:)' (at /Users/username/distActors/Sources/DistributedCluster/Cluster/ClusterEventStream.swift:152:14)

Stack dump:

0  swift-frontend           0x0000000105462c3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105461ec0 llvm::sys::RunSignalHandlers() + 128
2  swift-frontend           0x000000010546327c SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018d1314c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018d119ee0 pthread_kill + 288
5  libsystem_c.dylib        0x000000018d054340 abort + 168
6  swift-frontend           0x00000001054ccd2c (anonymous namespace)::MemoryLifetimeVerifier::reportError(llvm::Twine const&, int, swift::SILInstruction*) (.cold.2) + 0
7  swift-frontend           0x0000000100d9a1b8 std::__1::__function::__func<(anonymous namespace)::MemoryLifetimeVerifier::verify()::$_0, std::__1::allocator<(anonymous namespace)::MemoryLifetimeVerifier::verify()::$_0>, void (swift::SILBasicBlock*)>::~__func() + 0
8  swift-frontend           0x0000000100d999f4 (anonymous namespace)::MemoryLifetimeVerifier::require(llvm::SmallBitVector const&, llvm::Twine const&, swift::SILInstruction*, bool) + 1444
9  swift-frontend           0x0000000100d98ec4 (anonymous namespace)::MemoryLifetimeVerifier::checkBlock(swift::SILBasicBlock*, llvm::SmallBitVector&) + 3980
10 swift-frontend           0x0000000100d9a3c8 std::__1::__function::__func<(anonymous namespace)::MemoryLifetimeVerifier::verify()::$_0, std::__1::allocator<(anonymous namespace)::MemoryLifetimeVerifier::verify()::$_0>, void (swift::SILBasicBlock*)>::operator()(swift::SILBasicBlock*&&) + 436
11 swift-frontend           0x0000000100d6c634 swift::MemoryLocations::handleSingleBlockLocations(std::__1::function<void (swift::SILBasicBlock*)>) + 180
12 swift-frontend           0x0000000100d97a2c swift::SILFunction::verifyMemoryLifetime() + 4880
13 swift-frontend           0x0000000100da4818 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 8856
14 swift-frontend           0x0000000100d9e74c swift::SILFunction::verify(bool) const + 76
15 swift-frontend           0x000000010115ffdc swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 228
16 swift-frontend           0x000000010115f438 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6928
17 swift-frontend           0x0000000101160ef8 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef, bool) + 384
18 swift-frontend           0x0000000101161110 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 352
19 swift-frontend           0x000000010121d4bc (anonymous namespace)::SILGenType::emitType() + 400
20 swift-frontend           0x000000010121d320 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
21 swift-frontend           0x0000000101163068 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1788
22 swift-frontend           0x0000000101212e08 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&) + 148
23 swift-frontend           0x0000000101166f28 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 400
24 swift-frontend           0x0000000101163b70 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 140
25 swift-frontend           0x0000000100bdee94 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1060
26 swift-frontend           0x0000000100beda5c withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
27 swift-frontend           0x0000000100be09d4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3256
28 swift-frontend           0x0000000100a49828 swift::mainEntry(int, char const**) + 3136
29 dyld                     0x000000010e9a1088 start + 516

Steps to reproduce

  1. Create a new directory.
  2. Inside the new directory, run: git clone https://github.com/apple/swift-distributed-actors.git
  3. Run: swift run --package-path Samples/Sources/SampleDiningPhilosophers

The commit number for the distributed actors repository in this case is 247f23a.

Expected behavior
The compilation process should succeed, and the example should run.

Environment
This happens to fail with toolchains: 2022-09-27a, 2022-11-03a, and 2023-01-02a on an M1. Also fails with 2022-11-03a on x86.

Metadata

Metadata

Assignees

Labels

SILGenArea → compiler: The SIL generation stageactorFeature → concurrency: `actor` declarationsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of softwaredistributedFeature → concurrency: distributed actorswift 5.8verifier

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions