-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
Title describes it. I am calling a C function from Epoll via CEpoll that accepts a UnsafeMutablePointer<epoll_event>
, but using native Swift code results in the same crash.
Reproduction
func test() {
var inlineArray:InlineArray<1, Int> = .init(repeating: 0)
accept(&inlineArray)
}
func accept(_ pointer: UnsafeMutablePointer<Int>) {
}
Also crashes if passed as an UnsafePointer<Int>
, UnsafeRawPointer
or UnsafeMutableRawPointer
.
Stack dump
ArrayToPointer does not convert from array:
(array_to_pointer implicit type="UnsafeMutablePointer<Int>" location=/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:16 range=[/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:16 - line:234:17]
(inout_expr type="inout InlineArray<1, Int>" location=/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:16 range=[/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:16 - line:234:17]
(declref_expr type="@lvalue InlineArray<1, Int>" location=/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:17 range=[/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:17 - line:234:17] decl="Destiny.(file).EpollProcessor.test().inlineArray@/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:233: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: /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend -frontend -c /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Destiny.swift -primary-file /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Server.swift /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Socket.swift /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/commands/StopCommand.swift -emit-dependencies-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Destiny.build/Epoll.d -emit-reference-dependencies-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Destiny.build/Epoll.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Modules -color-diagnostics -Xcc -fcolor-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -load-plugin-executable /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/DestinyMacros-tool#DestinyMacros -load-plugin-executable /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/DestinyUtilityMacros-tool#DestinyUtilityMacros -empty-abi-descriptor -enable-anonymous-context-mangled-names -file-compilation-dir /home/paradigm/Desktop/GitProjects/destiny -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include/module.modulemap -Xcc -I -Xcc /home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/CEpoll/module.modulemap -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include/module.modulemap -Xcc -I -Xcc /home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/CEpoll/module.modulemap -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -no-auto-bridging-header-chaining -module-name Destiny -package-name destiny -in-process-plugin-server-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/lib/swift/host/plugins -plugin-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/local/lib/swift/host/plugins -parse-as-library -o /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Destiny.build/Epoll.swift.o -index-store-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1. Swift version 6.2-dev (LLVM 81ab6d9f7e4810f, Swift 9cc1947527bacea)
2. Compiling with effective version 5.10
3. While walking into 'EpollProcessor' (at /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:154:14)
4. While walking into body of 'test()' (at /home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:232:12)
5. While verifying ArrayToPointer expression at [/home/paradigm/Desktop/GitProjects/destiny/Sources/Destiny/Epoll.swift:234:16 - line:234:17] RangeText="&"
#0 0x000059eb9e675408 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x8bb8408)
#1 0x000059eb9e672fae llvm::sys::RunSignalHandlers() (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x8bb5fae)
#2 0x000059eb9e675aa1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007b40b544bcd0 (/usr/lib/libc.so.6+0x3dcd0)
#4 0x00007b40b54a5624 __pthread_kill_implementation /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:44:76
#5 0x00007b40b544bba0 raise /usr/src/debug/glibc/glibc/signal/../sysdeps/posix/raise.c:27:6
#6 0x00007b40b5433582 abort /usr/src/debug/glibc/glibc/stdlib/abort.c:81:3
#7 0x000059eb98650d92 swift::ASTWalker::PostWalkResult<swift::ArrayToPointerExpr*> (anonymous namespace)::Verifier::dispatchVisitPost<swift::ArrayToPointerExpr*>(swift::ArrayToPointerExpr*) ASTVerifier.cpp:0:0
#8 0x000059eb986422ee (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) ASTVerifier.cpp:0:0
#9 0x000059eb9865a1e6 (anonymous namespace)::Traversal::doIt(swift::Expr*) ASTWalker.cpp:0:0
#10 0x000059eb98660ae4 (anonymous namespace)::Traversal::visit(swift::ArgumentList*) ASTWalker.cpp:0:0
#11 0x000059eb9865c9de (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) ASTWalker.cpp:0:0
#12 0x000059eb9865a24f (anonymous namespace)::Traversal::doIt(swift::Expr*) ASTWalker.cpp:0:0
#13 0x000059eb9865cc27 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) ASTWalker.cpp:0:0
#14 0x000059eb986607fd (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) ASTWalker.cpp:0:0
#15 0x000059eb9865ef2c (anonymous namespace)::Traversal::visit(swift::Decl*) ASTWalker.cpp:0:0
#16 0x000059eb9865af83 (anonymous namespace)::Traversal::doIt(swift::Decl*) ASTWalker.cpp:0:0
#17 0x000059eb986602ff (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) ASTWalker.cpp:0:0
#18 0x000059eb9865ef1b (anonymous namespace)::Traversal::visit(swift::Decl*) ASTWalker.cpp:0:0
#19 0x000059eb9865af83 (anonymous namespace)::Traversal::doIt(swift::Decl*) ASTWalker.cpp:0:0
#20 0x000059eb9865ae83 swift::Decl::walk(swift::ASTWalker&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x2b9de83)
#21 0x000059eb9887a09f swift::SourceFile::walk(swift::ASTWalker&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x2dbd09f)
#22 0x000059eb98641238 swift::verify(swift::SourceFile&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x2b84238)
#23 0x000059eb989d1bd7 swift::TypeCheckPrimaryFileRequest::cacheResult(std::tuple<>) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x2f14bd7)
#24 0x000059eb9820175d swift::performTypeChecking(swift::SourceFile&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x274475d)
#25 0x000059eb96d63f79 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_8>(long, swift::SourceFile&) Frontend.cpp:0:0
#26 0x000059eb96d55c4a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x1298c4a)
#27 0x000059eb96d55a3b swift::CompilerInstance::performSema() (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0x1298a3b)
#28 0x000059eb96a05572 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#29 0x000059eb969f688e performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#30 0x000059eb969f59bf swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0xf389bf)
#31 0x000059eb9678507a swift::mainEntry(int, char const**) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0xcc807a)
#32 0x00007b40b5435488 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#33 0x00007b40b543554c call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20
#34 0x00007b40b543554c __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5
#35 0x000059eb96784075 _start (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-04-12/usr/bin/swift-frontend+0xcc7075)
Expected behavior
Successfully compile or show a diagnostic.
Environment
swiftc -version
Swift version 6.2-dev (LLVM 81ab6d9f7e4810f, Swift 9cc1947)
Target: x86_64-unknown-linux-gnu
Build config: +assertions
Swift Toolchain
main-snapshot-2025-04-12
OS
Arch Linux (6.14.3-arch1-1)
IDE
VS Code (1.99.3)
Swift VS Code Extension
2.2.0
Swiftly
1.0.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels