Skip to content

Compiler crashed when passing an actor's stored property to a function's isolated parameter #81019

Open
@rayx

Description

@rayx

Description

See title.

Reproduction

func isolatedPrint(on actor: isolated C) {
   print("hello")
}

actor C {
    var value = 0
    var other = C()

    func test() {
        Task {
            isolatedPrint(on: other)
        }
    }
}

I tried on both macOS (Swift 6.0.1) and Linux (Swift 6.0.3). It crashed on both systems.

Stack dump

Below is stack trace on Linux:

 # swift build
Building for debugging...
error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend -frontend -c -primary-file /var/tmp/sandbox/swift/isolated_param_nongeneric/Sources/main.swift -emit-dependencies-path /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/isolated_param_nongeneric.build/main.d -emit-reference-dependencies-path /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/isolated_param_nongeneric.build/main.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/Modules -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -entry-point-function-name isolated_param_nongeneric_main -empty-abi-descriptor -resource-dir /var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /var/tmp/sandbox/swift/isolated_param_nongeneric -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name isolated_param_nongeneric -package-name isolated_param_nongeneric -plugin-path /var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/lib/swift/host/plugins -plugin-path /var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/local/lib/swift/host/plugins -o /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/isolated_param_nongeneric.build/main.swift.o -index-store-path /var/tmp/sandbox/swift/isolated_param_nongeneric/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1.	Swift version 6.0.3 (swift-6.0.3-RELEASE)
2.	Compiling with the current language version
3.	While evaluating request TypeCheckSourceFileRequest(source_file "/var/tmp/sandbox/swift/isolated_param_nongeneric/Sources/main.swift")
4.	While evaluating request TypeCheckFunctionBodyRequest(isolated_param_nongeneric.(file).C.test()@/var/tmp/sandbox/swift/isolated_param_nongeneric/Sources/main.swift:9:10)
 #0 0x000055996a7e6bc7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x670fbc7)
 #1 0x000055996a7e4b8e llvm::sys::RunSignalHandlers() (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x670db8e)
 #2 0x000055996a7e723a SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f766fcb1520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00005599663291b8 swift::ActorIsolation::isDistributedActor() const (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x22521b8)
 #5 0x0000559965d755f9 (anonymous namespace)::ActorIsolationChecker::checkApply(swift::ApplyExpr*) TypeCheckConcurrency.cpp:0:0
 #6 0x0000559965d722f3 (anonymous namespace)::ActorIsolationChecker::walkToExprPre(swift::Expr*) TypeCheckConcurrency.cpp:0:0
 #7 0x00005599662ba320 (anonymous namespace)::Traversal::visit(swift::Stmt*) ASTWalker.cpp:0:0
 #8 0x00005599662ba2bf (anonymous namespace)::Traversal::visit(swift::Stmt*) ASTWalker.cpp:0:0
 #9 0x00005599662b704a (anonymous namespace)::Traversal::visitClosureExpr(swift::ClosureExpr*) ASTWalker.cpp:0:0
#10 0x00005599662b5bc8 (anonymous namespace)::Traversal::visit(swift::Expr*) ASTWalker.cpp:0:0
#11 0x00005599662b7cc0 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visitFunctionConversionExpr(swift::FunctionConversionExpr*) ASTWalker.cpp:0:0
#12 0x00005599662b5cdd (anonymous namespace)::Traversal::visit(swift::Expr*) ASTWalker.cpp:0:0
#13 0x00005599662bd10b (anonymous namespace)::Traversal::visit(swift::ArgumentList*) ASTWalker.cpp:0:0
#14 0x00005599662b9d7f (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) ASTWalker.cpp:0:0
#15 0x00005599662b5a2c (anonymous namespace)::Traversal::visit(swift::Expr*) ASTWalker.cpp:0:0
#16 0x00005599662ba1cc (anonymous namespace)::Traversal::visit(swift::Stmt*) ASTWalker.cpp:0:0
#17 0x00005599662b51e1 swift::Stmt::walk(swift::ASTWalker&) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x21de1e1)
#18 0x0000559965d69b9f swift::checkFunctionActorIsolation(swift::AbstractFunctionDecl*) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x1c92b9f)
#19 0x0000559965e5eb7b swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x1d87b7b)
#20 0x00005599663acc35 swift::TypeCheckFunctionBodyRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()>(swift::TypeCheckFunctionBodyRequest const&, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()) crtstuff.c:0:0
#21 0x0000559966323533 swift::AbstractFunctionDecl::getTypecheckedBody() const (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x224c533)
#22 0x000055996644dad9 swift::SourceFile::typeCheckDelayedFunctions() (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x2376ad9)
#23 0x0000559965ea36c8 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x1dcc6c8)
#24 0x0000559965ea55ae swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) crtstuff.c:0:0
#25 0x0000559965ea35c5 swift::performTypeChecking(swift::SourceFile&) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x1dcc5c5)
#26 0x0000559964daf4b9 swift::CompilerInstance::performSema() (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0xcd84b9)
#27 0x0000559964b2cf09 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#28 0x0000559964b2c1d6 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0xa551d6)
#29 0x00005599649033b7 swift::mainEntry(int, char const**) (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x82c3b7)
#30 0x00007f766fc98d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007f766fc98e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007f766fc98e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x0000559964901ad5 _start (/var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend+0x82aad5)

*** Signal 11: Backtracing from 0x5599663291b8... done ***

*** Program crashed: Bad pointer dereference at 0x0000000000000038 ***

Thread 0 "swift-frontend" crashed:

0  0x00005599663291b8 swift::ActorIsolation::isDistributedActor() const + 24 in swift-frontend


Registers:

rax 0x0000000000000000  0
rdx 0x0000000000000000  0
rcx 0x0000000004002034  67117108
rbx 0x0000000000000004  4
rsi 0x00007ffe99af0820  e0 df b3 91 99 55 00 00 e0 5e ad 91 99 55 00 00  àß³··U··à^­··U··
rdi 0x0000559991b64548  12 20 00 00 00 00 00 00 e0 df b3 91 99 55 00 00  · ······àß³··U··
rbp 0x00007ffe99af0968  72 ac b2 91 99 55 00 00 01 00 00 00 00 00 00 00  r¬²··U··········
rsp 0x00007ffe99af08a0  08 60 ad 91 99 55 00 00 fe 00 00 00 00 00 00 00  ·`­··U··þ·······
 r8 0x22481fb655fcb97d  2470259263599851901
 r9 0x784284fae7868e40  8665634846175301184
r10 0x0000559991a84288  18 5e 02 00 00 00 00 00 16 00 00 00 00 00 00 00  ·^··············
r11 0x0000000000025e18  155160
r12 0x0000559991b645a8  43 01 00 00 00 00 00 00 c0 67 ad 91 99 55 00 00  C·······Àg­··U··
r13 0x0000559991ad6008  3d 00 00 00 00 00 00 00 70 4c 82 91 99 55 00 00  =·······pL···U··
r14 0x00000000000000fe  254
r15 0x00007ffe99af12e8  d0 1e 4f 6b 99 55 00 00 03 00 00 00 99 55 00 00  зOk·U·······U··
rip 0x00005599663291b8  48 8b 48 38 48 89 cf 48 83 e7 fc 31 c0 f6 c1 02  H·H8H·ÏH·çü1ÀöÁ·

rflags 0x0000000000010202  

cs 0x0033  fs 0x0000  gs 0x0000


Images (26 omitted):

0x00005599640d7000–0x000055996b4b16e0 8e0005db0dddea8bdd7be09b9256d2bd43fd283f swift-frontend /var/tmp/swift-6.0.3-RELEASE-ubuntu22.04/usr/bin/swift-frontend

Backtrace took 0.28s

Expected behavior

It shouldn't crash.

Environment

% swift --version
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

The following code has the same issue. The only difference is that the function is generic.

func isolatedPrint<A : Actor>(on actor: isolated A) {
   print("hello")
}

actor C {
    var value = 0
    var other = C()

    func test() {
        Task {
            isolatedPrint(on: other)
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions