-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
If you don't spell the type of an imported function properly, the SIL deserializer crashes because you lied to it when using -enable-experimental-feature Extern
Reproduction
Link a custom main.swift to the Testing library, and attempt to import its entry point getter with the wrong return type:
import Foundation
typealias EntryPoint = @convention(thin) @Sendable (_ configurationJSON: UnsafeRawBufferPointer?, _ recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void) async throws -> Bool
@_extern(c, "swt_abiv0_getEntryPoint")
func swt_abiv0_getEntryPoint() -> UnsafeMutableRawPointer
// ^^^ Should be UnsafeRawPointer
@main struct Runner {
static func main() async throws {
let configurationJSON: UnsafeRawBufferPointer? = nil
let recordHandler: @Sendable (UnsafeRawBufferPointer) -> Void = { _ in }
let entryPoint = unsafeBitCast(swt_abiv0_getEntryPoint(), to: EntryPoint.self)
if try await entryPoint(configurationJSON, recordHandler) {
exit(EXIT_SUCCESS)
} else {
exit(EXIT_FAILURE)
}
}
}Stack dump
[1/5] Building Swift Module 'TestGCSwift' with 2 sources
FAILED: Lagom/Tests/LibGC/CMakeFiles/TestGCSwift.dir/TestGCBindings.swift.o Lagom/Tests/LibGC/CMakeFiles/TestGCSwift.dir/__/Resources/SwiftTestMain.swift.o
/home/andrew/.local/bin/swiftc -j 32 -num-threads 32 -c -DENABLE_COMPILETIME_FORMAT_CHECK -D_FILE_OFFSET_BITS=64 -module-name TestGCSwift -O -g -incremental -color-diagnostics -enable-experimental-feature Extern -Xcc -Wall -Xcc -Wextra -Xcc -fno-exceptions -Xcc -ffp-contract=off -Xcc -Wcast-qual -Xcc -Wformat=2 -Xcc -Wimplicit-fallthrough -Xcc -Wlogical-op -Xcc -Wmissing-declarations -Xcc -Wmissing-field-initializers -Xcc -Wsuggest-override -Xcc -Wno-invalid-offsetof -Xcc -Wno-unknown-warning-option -Xcc -Wno-unused-command-line-argument -Xcc -Werror -Xcc -fconstexpr-steps=16777216 -Xcc -Wmissing-prototypes -Xcc -Wno-implicit-const-int-float-conversion -Xcc -Wno-user-defined-literals -Xcc -Wno-vla-cxx-extension -Xcc -Wno-unqualified-std-cast-call -Xcc -fno-semantic-interposition -Xcc -fvisibility-inlines-hidden -Xcc -fstack-protector-strong -Xcc -fstrict-flex-arrays=2 -Xcc -Wno-maybe-uninitialized -Xcc -Wno-shorten-64-to-32 -Xcc -fsigned-char -Xcc -ggnu-pubnames -Xcc -fPIC -Xcc -O2 -Xcc -g1 -Xcc -Wno-overloaded-virtual -Xcc -Wno-unused-private-field -Xcc -ivfsoverlay/home/andrew/ladybird-org/ladybird-browser/Build/release/vfs_overlays/AK_vfs_overlay.yaml -Xcc -std=c++23 -cxx-interoperability-mode=default -Xcc -ivfsoverlay/home/andrew/ladybird-org/ladybird-browser/Build/release/vfs_overlays/LibGC_vfs_overlay.yaml -load-plugin-library /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift/host/plugins/libTestingMacros.so -output-file-map Lagom/Tests/LibGC/CMakeFiles/TestGCSwift.dir/RelWithDebInfo/output-file-map.json -I /home/andrew/ladybird-org/ladybird-browser -I /home/andrew/ladybird-org/ladybird-browser/Services -I /home/andrew/ladybird-org/ladybird-browser/Libraries -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Services -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Libraries -I /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/include -I /home/andrew/ladybird-org/ladybird-browser/Meta/Lagom/../.. -I /home/andrew/ladybird-org/ladybird-browser/Meta/Lagom/../../Libraries -I /home/andrew/ladybird-org/ladybird-browser/Meta/Lagom/../../Services -I /home/andrew/ladybird-org/ladybird-browser/Build/release -I /home/andrew/ladybird-org/ladybird-browser/Tests/LibGC -I /home/andrew/ladybird-org/ladybird-browser/Build/release/swift -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/AK/include -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Libraries/LibGC/include /home/andrew/ladybird-org/ladybird-browser/Tests/LibGC/TestGCBindings.swift /home/andrew/ladybird-org/ladybird-browser/Tests/Resources/SwiftTestMain.swift
warning: conditional compilation flags do not have values in Swift; they are either present or absent (rather than '_FILE_OFFSET_BITS=64')
error: compile command failed due to signal 6 (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: /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend -frontend -c /home/andrew/ladybird-org/ladybird-browser/Tests/LibGC/TestGCBindings.swift -primary-file /home/andrew/ladybird-org/ladybird-browser/Tests/Resources/SwiftTestMain.swift -emit-reference-dependencies-path Lagom/Tests/LibGC/CMakeFiles/TestGCSwift.dir/__/Resources/SwiftTestMain.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -cxx-interoperability-mode=default -I /home/andrew/ladybird-org/ladybird-browser -I /home/andrew/ladybird-org/ladybird-browser/Services -I /home/andrew/ladybird-org/ladybird-browser/Libraries -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Services -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Libraries -I /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/include -I /home/andrew/ladybird-org/ladybird-browser -I /home/andrew/ladybird-org/ladybird-browser/Libraries -I /home/andrew/ladybird-org/ladybird-browser/Services -I /home/andrew/ladybird-org/ladybird-browser/Build/release -I /home/andrew/ladybird-org/ladybird-browser/Tests/LibGC -I /home/andrew/ladybird-org/ladybird-browser/Build/release/swift -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/AK/include -I /home/andrew/ladybird-org/ladybird-browser/Build/release/Lagom/Libraries/LibGC/include -color-diagnostics -g -debug-info-format=dwarf -dwarf-version=4 -O -D ENABLE_COMPILETIME_FORMAT_CHECK -D _FILE_OFFSET_BITS=64 -enable-experimental-feature Extern -empty-abi-descriptor -load-plugin-library /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift/host/plugins/libTestingMacros.so -resource-dir /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift -file-compilation-dir /home/andrew/ladybird-org/ladybird-browser/Build/release -Xcc -Wall -Xcc -Wextra -Xcc -fno-exceptions -Xcc -ffp-contract=off -Xcc -Wcast-qual -Xcc -Wformat=2 -Xcc -Wimplicit-fallthrough -Xcc -Wlogical-op -Xcc -Wmissing-declarations -Xcc -Wmissing-field-initializers -Xcc -Wsuggest-override -Xcc -Wno-invalid-offsetof -Xcc -Wno-unknown-warning-option -Xcc -Wno-unused-command-line-argument -Xcc -Werror -Xcc -fconstexpr-steps=16777216 -Xcc -Wmissing-prototypes -Xcc -Wno-implicit-const-int-float-conversion -Xcc -Wno-user-defined-literals -Xcc -Wno-vla-cxx-extension -Xcc -Wno-unqualified-std-cast-call -Xcc -fno-semantic-interposition -Xcc -fvisibility-inlines-hidden -Xcc -fstack-protector-strong -Xcc -fstrict-flex-arrays=2 -Xcc -Wno-maybe-uninitialized -Xcc -Wno-shorten-64-to-32 -Xcc -fsigned-char -Xcc -ggnu-pubnames -Xcc -fPIC -Xcc -O2 -Xcc -g1 -Xcc -Wno-overloaded-virtual -Xcc -Wno-unused-private-field -Xcc -ivfsoverlay/home/andrew/ladybird-org/ladybird-browser/Build/release/vfs_overlays/AK_vfs_overlay.yaml -Xcc -std=c++23 -Xcc -ivfsoverlay/home/andrew/ladybird-org/ladybird-browser/Build/release/vfs_overlays/LibGC_vfs_overlay.yaml -module-name TestGCSwift -in-process-plugin-server-path /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift/host/plugins -plugin-path /home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/local/lib/swift/host/plugins -enable-default-cmo -num-threads 32 -o Lagom/Tests/LibGC/CMakeFiles/TestGCSwift.dir/__/Resources/SwiftTestMain.swift.o
1. Swift version 6.1-dev (LLVM 5c0d283c37132bf, Swift b5af518638c9a16)
2. Compiling with effective version 5.10
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for TestGCSwift)
4. While running pass #196 SILModuleTransform "MandatorySILLinker".
5. While deserializing SIL function "swt_abiv0_getEntryPoint"
6. *** DESERIALIZATION FAILURE ***
*** If any module named here was modified in the SDK, please delete the ***
*** new swiftmodule files from the SDK and keep only swiftinterfaces. ***
module 'Testing', builder version '6.1(6.1)/Swift version 6.1-dev (LLVM 5c0d283c37132bf, Swift b5af518638c9a16)', built from source against SDK , resilient, loaded from '/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/lib/swift/linux/Testing.swiftmodule/x86_64-unknown-linux-gnu.swiftmodule'
SILFunction type mismatch for 'swt_abiv0_getEntryPoint': '$@convention(c) () -> UnsafeMutableRawPointer' != '$@convention(c) () -> UnsafeRawPointer'
#0 0x00005cbc1376c1d7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x85091d7)
#1 0x00005cbc13769d8e llvm::sys::RunSignalHandlers() (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x8506d8e)
#2 0x00005cbc1376c87a SignalHandler(int) Signals.cpp:0:0
#3 0x00007c9f0b645320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
#4 0x00007c9f0b69eb1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007c9f0b69eb1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007c9f0b69eb1c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007c9f0b64526e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007c9f0b6288ff abort ./stdlib/abort.c:81:7
#9 0x00005cbc0d1c11b7 swift::ModuleFileSharedCore::fatal(llvm::Error) const (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x1f5e1b7)
#10 0x00005cbc0d2c82ff swift::ModuleFile::diagnoseFatal(llvm::Error) const (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x20652ff)
#11 0x00005cbc0d29994a swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool, bool) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x203694a)
#12 0x00005cbc0d2adfc4 swift::SILDeserializer::lookupSILFunction(swift::SILFunction*, bool) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x204afc4)
#13 0x00005cbc0d25de08 swift::SerializedSILLoader::lookupSILFunction(swift::SILFunction*, bool) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x1ffae08)
#14 0x00005cbc0d54be6a swift::SILLinkerVisitor::deserializeAndPushToWorklist(swift::SILFunction*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x22e8e6a)
#15 0x00005cbc0d54c5eb swift::SILLinkerVisitor::process() (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x22e95eb)
#16 0x00005cbc0d54c387 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x22e9387)
#17 0x00005cbc0d3c0ec9 swift::SILModule::linkFunction(swift::SILFunction*, swift::SILModule::LinkingMode) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x215dec9)
#18 0x00005cbc0cc5cc96 (anonymous namespace)::SILLinker::run() Link.cpp:0:0
#19 0x00005cbc0cac5d02 swift::SILPassManager::runModulePass(unsigned int) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x1862d02)
#20 0x00005cbc0cac866a swift::SILPassManager::execute() (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x186566a)
#21 0x00005cbc0cac1dc8 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x185edc8)
#22 0x00005cbc0cac1d7d swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x185ed7d)
#23 0x00005cbc0cb15d6a swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) crtstuff.c:0:0
#24 0x00005cbc0caea526 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) crtstuff.c:0:0
#25 0x00005cbc0cac1fc0 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x185efc0)
#26 0x00005cbc0cb02961 swift::runSILDiagnosticPasses(swift::SILModule&) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x189f961)
#27 0x00005cbc0c45c547 swift::CompilerInstance::performSILProcessing(swift::SILModule*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0x11f9547)
#28 0x00005cbc0c0febb4 performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#29 0x00005cbc0c0fdb40 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0xe9ab40)
#30 0x00005cbc0c10eed5 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#31 0x00005cbc0c100ea0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#32 0x00005cbc0c0ffbda swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0xe9cbda)
#33 0x00005cbc0bed780e swift::mainEntry(int, char const**) (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0xc7480e)
#34 0x00007c9f0b62a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#35 0x00007c9f0b62a28b call_init ./csu/../csu/libc-start.c:128:20
#36 0x00007c9f0b62a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#37 0x00005cbc0bed68a5 _start (/home/andrew/.local/share/swiftly/toolchains/main-snapshot-2024-11-09/usr/bin/swift-frontend+0xc738a5)
Expected behavior
A compiler error saying "Hey, that symbol has a different type when I read it from disk than what you spelled in the source code!" ... instead of a crash
Environment
$ swiftc -version
Swift version 6.1-dev (LLVM 5c0d283c37132bf, Swift b5af518)
Target: x86_64-unknown-linux-gnu
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