Custom functions broken on Linux

Open
#1,071 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
sqlite, swift
Domain
databases

Research direction

Read Swift issue 47006 first to understand the reported Linux runtime failure. Then inspect CustomFunctions.swift, Connection.swift, and CustomFunctionsTests.swift, especially CustomFunctionWithTwoArgsTests.testFunctionLeftResultOptional and the createFunction entry points. Done would mean custom functions no longer trigger the Linux crash, with the relevant tests passing or the limitation documented if no safe workaround exists.

Written by the indexing model from the issue text.

Description

bug linux swift bug

Caused by this bug in Swift:

https://github.com/apple/swift/issues/47006

Not much we can do at this point, except avoiding this construct.

* thread #1, name = 'SQLite.swiftPac', stop reason = signal SIGSEGV: invalid address (fault address: 0x50)
  * frame #0: 0x00007ffff7e1945c libswiftCore.so`swift::MetadataCacheEntryBase<(anonymous namespace)::TupleCacheEntry, swift::TargetTupleTypeMetadata<swift::InProcess>::Element>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 380
    frame #1: 0x00007ffff7e0ad4d libswiftCore.so`std::pair<(anonymous namespace)::TupleCacheEntry*, swift::MetadataResponse> swift::LockingConcurrentMap<(anonymous namespace)::TupleCacheEntry, (anonymous namespace)::TupleCacheStorage>::getOrInsert<(anonymous namespace)::TupleCacheEntry::Key, swift::MetadataRequest&, swift::TargetValueWitnessTable<swift::InProcess> const*&>((anonymous namespace)::TupleCacheEntry::Key, swift::MetadataRequest&, swift::TargetValueWitnessTable<swift::InProcess> const*&) + 3373
    frame #2: 0x00007ffff7e09c7a libswiftCore.so`swift_getTupleTypeMetadata + 250
    frame #3: 0x00007ffff7e270b9 libswiftCore.so`swift::Demangle::__runtime::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::__runtime::Node*) + 9945
    frame #4: 0x00007ffff7e25467 libswiftCore.so`swift::Demangle::__runtime::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::__runtime::Node*) + 2695
    frame #5: 0x00007ffff7e24115 libswiftCore.so`swift_getTypeByMangledNodeImpl(swift::MetadataRequest, swift::Demangle::__runtime::Demangler&, swift::Demangle::__runtime::Node*, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 437
    frame #6: 0x00007ffff7e23f10 libswiftCore.so`swift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::__runtime::Demangler&, swift::Demangle::__runtime::Node*, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 384
    frame #7: 0x00007ffff7e24636 libswiftCore.so`swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 1046
    frame #8: 0x00007ffff7e21ec0 libswiftCore.so`swift::swift_getTypeByMangledName(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 384
    frame #9: 0x00007ffff7e220fa libswiftCore.so`swift_getTypeByMangledNameInContext + 170
    frame #10: 0x000055555557a7dd SQLite.swiftPackageTests.xctest`__swift_instantiateConcreteTypeFromMangledName at <compiler-generated>:0
    frame #11: 0x000055555558214f SQLite.swiftPackageTests.xctest`Connection.createFunction(function="test", argumentCount=2, deterministic=true, block=0x00005555555b8a80 SQLite.swiftPackageTests.xctest`partial apply forwarder for closure #1 (Swift.Array<Swift.Optional<SQLite.Binding>>) -> Swift.Optional<SQLite.Binding> in SQLite.Connection.createFunction<A where A: SQLite.Value>(Swift.String, Swift.UInt, Swift.Bool, (Swift.Array<Swift.Optional<SQLite.Binding>>) -> Swift.Optional<A>) throws -> (Swift.Array<SQLite.Expressible>) -> SQLite.Expression<Swift.Optional<A>> at <compiler-generated>, self=0x0000555555a01050) at Connection.swift:643:35
    frame #12: 0x00005555555afb75 SQLite.swiftPackageTests.xctest`Connection.createFunction<Z>(function="test", argumentCount=2, deterministic=true, block=0x5555555b5100, self=0x0000555555a01050) at CustomFunctions.swift:154:9
    frame #13: 0x00005555555b4c3c SQLite.swiftPackageTests.xctest`Connection.createFunction<Z, A, B>(function="test", deterministic=true, block=0x555555645470, self=0x0000555555a01050) at CustomFunctions.swift:120:22
    frame #14: 0x0000555555644b6e SQLite.swiftPackageTests.xctest`CustomFunctionWithTwoArgsTests.testFunctionLeftResultOptional(self=0x0000555555867d20) at CustomFunctionsTests.swift:115:53
Dominant language
Swift
Stars
10.2k
Forks
1.6k
Avg merge
6d 2h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stephencelis/SQLite.swift

All issues in stephencelis/SQLite.swift

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.