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

Regression in Swift 6.0 compiler: crash with passing & to non-inout parameter #73454

Open
migueldeicaza opened this issue May 6, 2024 · 0 comments
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 Frontend Area → compiler: Frontend inout Feature → types: `inout` types type checker Area → compiler: Semantic analysis

Comments

@migueldeicaza
Copy link

Description

There is a crash when compiling existing code from 5.10 with the 6.0 toolchain

Reproduction

func set_density (_ density: Double) {
        var copy_density = density
        
       object_method_bind_ptrcall_v (&copy_density)
    }

    func object_method_bind_ptrcall_v(
        _ _args: UnsafeMutableRawPointer?...
    ) {
    }

Stack dump

error: compile command failed due to signal 6 (use -v to see invocation)
InOutToPointerExpr in unexpected position!
(inout_to_pointer implicit type="UnsafeMutableRawPointer" location=b.swift:5:38 range=[b.swift:5:38 - line:5:39]
  (inout_expr type="inout Double" location=b.swift:5:38 range=[b.swift:5:38 - line:5:39]
    (declref_expr type="@lvalue Double" location=b.swift:5:39 range=[b.swift:5:39 - line:5:39] decl="b.(file).set_density(_:).copy_density@b.swift:3:13" function_ref=unapplied)))
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-30-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file b.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-30-a.xctoolchain/usr/lib/swift -module-name b -plugin-path /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-30-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-30-a.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/tm/n1hppdss541c9cz05t2jt6ch0000gn/T/TemporaryDirectory.9isijr/b-1.o
1.	Apple Swift version 6.0-dev (LLVM 7b8e6346027d2b1, Swift 763421cee31dc8f)
2.	Compiling with effective version 5.10
3.	While walking into body of 'set_density(_:)' (at b.swift:2:1)
4.	While verifying InOutToPointer expression at [b.swift:5:38 - line:5:39] RangeText="&"
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           0x00000001079c93b4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001079c7b80 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001079c99fc SignalHandler(int) + 304
3  libsystem_platform.dylib 0x0000000181a3da24 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000181a0dcc0 pthread_kill + 288
5  libsystem_c.dylib        0x0000000181919a40 abort + 180
6  swift-frontend           0x0000000107eab9e0 swift::ASTWalker::PostWalkResult<swift::InOutToPointerExpr*> (anonymous namespace)::Verifier::dispatchVisitPost<swift::InOutToPointerExpr*>(swift::InOutToPointerExpr*) (.cold.3) + 0
7  swift-frontend           0x0000000103b91494 swift::ASTWalker::PostWalkResult<swift::InOutToPointerExpr*> (anonymous namespace)::Verifier::dispatchVisitPost<swift::InOutToPointerExpr*>(swift::InOutToPointerExpr*) + 556
8  swift-frontend           0x0000000103b85004 (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 1784
9  swift-frontend           0x0000000103b99d4c (anonymous namespace)::Traversal::doIt(swift::Expr*) + 988
10 swift-frontend           0x0000000103b99a20 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 176
11 swift-frontend           0x0000000103b9b794 (anonymous namespace)::Traversal::visitCollectionExpr(swift::CollectionExpr*) + 80
12 swift-frontend           0x0000000103b99a74 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 260
13 swift-frontend           0x0000000103b99a20 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 176
14 swift-frontend           0x0000000103b9e460 swift::ArgumentList* llvm::function_ref<swift::ArgumentList* (swift::ArgumentList*)>::callback_fn<(anonymous namespace)::Traversal::doIt(swift::ArgumentList*)::'lambda'(swift::ArgumentList*)>(long, swift::ArgumentList*) + 264
15 swift-frontend           0x0000000103b9e2f4 swift::ArgumentList* (anonymous namespace)::Traversal::traverse<swift::ArgumentList>(swift::ASTWalker::PreWalkResult<swift::ArgumentList*>, llvm::function_ref<swift::ArgumentList* (swift::ArgumentList*)>, llvm::function_ref<swift::ASTWalker::PostWalkResult<swift::ArgumentList*> (swift::ArgumentList*)>) + 84
16 swift-frontend           0x0000000103b9b96c (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 108
17 swift-frontend           0x0000000103b99a4c (anonymous namespace)::Traversal::doIt(swift::Expr*) + 220
18 swift-frontend           0x0000000103b9bd14 swift::Stmt* llvm::function_ref<swift::Stmt* (swift::Stmt*)>::callback_fn<(anonymous namespace)::Traversal::doIt(swift::Stmt*)::'lambda'(swift::Stmt*)>(long, swift::Stmt*) + 380
19 swift-frontend           0x0000000103b9bb34 swift::Stmt* (anonymous namespace)::Traversal::traverse<swift::Stmt>(swift::ASTWalker::PreWalkResult<swift::Stmt*>, llvm::function_ref<swift::Stmt* (swift::Stmt*)>, llvm::function_ref<swift::ASTWalker::PostWalkResult<swift::Stmt*> (swift::Stmt*)>) + 84
20 swift-frontend           0x0000000103b9e114 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 660
21 swift-frontend           0x0000000103b9cf00 (anonymous namespace)::Traversal::visit(swift::Decl*) + 156
22 swift-frontend           0x0000000103b9a3e8 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 288
23 swift-frontend           0x0000000103b9a2bc swift::Decl::walk(swift::ASTWalker&) + 32
24 swift-frontend           0x0000000103d47670 swift::SourceFile::walk(swift::ASTWalker&) + 196
25 swift-frontend           0x0000000103b8407c swift::verify(swift::SourceFile&) + 96
26 swift-frontend           0x0000000103e5f0f0 swift::TypeCheckSourceFileRequest::cacheResult(std::__1::tuple<>) const + 76
27 swift-frontend           0x00000001038977a4 swift::performTypeChecking(swift::SourceFile&) + 92
28 swift-frontend           0x000000010279db5c bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_7>(long, swift::SourceFile&) + 16
29 swift-frontend           0x00000001027975b4 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
30 swift-frontend           0x0000000102797548 swift::CompilerInstance::performSema() + 76
31 swift-frontend           0x000000010256cd98 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
32 swift-frontend           0x000000010255e1c8 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
33 swift-frontend           0x000000010255d134 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2368
34 swift-frontend           0x000000010237792c swift::mainEntry(int, char const**) + 3096
35 dyld                     0x000000018168d0e0 start + 2360

Expected behavior

Not crash.

Environment

Apple Swift version 6.0-dev (LLVM 7b8e6346027d2b1, Swift 763421c)
Target: arm64-apple-macosx14.0

Additional information

No response

@migueldeicaza migueldeicaza 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 May 6, 2024
@ktoso ktoso added Frontend Area → compiler: Frontend inout Feature → types: `inout` types and removed triage needed This issue needs more specific labels labels May 14, 2024
@ktoso ktoso changed the title Regression in Swift 6.0 compiler Regression in Swift 6.0 compiler: crash with passing & to non-inout parameter May 14, 2024
@ktoso ktoso added type checker Area → compiler: Semantic analysis compiler The Swift compiler in itself Frontend Area → compiler: Frontend and removed Frontend Area → compiler: Frontend type checker Area → compiler: Semantic analysis labels May 14, 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 Frontend Area → compiler: Frontend inout Feature → types: `inout` types type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants