Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

recursivelyAllWritableKeyPaths crash in specific case #476

Open
@ematejska

Description

@ematejska

Imported from JIRA https://bugs.swift.org/browse/TF-1207

Type: Bug Priority: Minor
Reporter: Takehiro Araki Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment: swift-tensorflow-RELEASE-0.8.xctoolchain

If the target type has both Scalar parameter and Activation parameter, recursivelyAllWritableKeyPaths crash.

struct Model<Scalar: FloatingPoint&Differentiable>: KeyPathIterable {
    let scale: Scalar = 0
    let activation: Activation = { $0 }
    typealias Activation = @differentiable (Scalar) -> Scalar
}

let model = Model<Float>()
for kp in model.recursivelyAllWritableKeyPaths(to: Float.self) {
    print(model[keyPath: kp])
}
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.8.xctoolchain/usr/bin/swift -frontend -interpret main.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name main 
1.	Swift version 5.2-dev (LLVM b3057cffb6, Swift da7410955d)
2.	While running user code "main.swift"
0  swift                    0x0000000112971e75 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001129710b5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000011297245c SignalHandler(int) + 268
3  libsystem_platform.dylib 0x00007fff781b5b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00000000000004b8 _sigtramp + 18446603338501106040
5  libswiftCore.dylib       0x000000011a97c059 $ss15KeyPathIterablePsE014recursivelyAllA5PathsSays07PartialaB0CyxGGvg + 1017
6  libswiftCore.dylib       0x000000011a97d602 $ss15KeyPathIterablePsE014recursivelyAllA5Paths2toSays0aB0Cyxqd__GGqd__m_tlF + 34
7  libswiftCore.dylib       0x000000011a97d91a $ss15KeyPathIterablePsE011allWritableA5Paths2toSays0eaB0Cyxqd__GGqd__m_tlFTm + 26
8  libswiftCore.dylib       0x000000011b0070ed $ss15KeyPathIterablePsE011allWritableA5Paths2toSays0eaB0Cyxqd__GGqd__m_tlFTm + 6854637
9  swift                    0x000000010e8d5a58 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 456
10 swift                    0x000000010e8d8bf1 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1297
11 swift                    0x000000010e8cbbdf swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) + 3471
12 swift                    0x000000010e8b494a performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 2378
13 swift                    0x000000010e8a9363 performCompile(swift::CompilerInstance&, swift::CompilerInvocation const&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 9299
14 swift                    0x000000010e8a5f48 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4472
15 swift                    0x000000010e83887d main + 861
16 libdyld.dylib            0x00007fff77fca3d5 start + 1
17 libdyld.dylib            0x000000000000000a start + 18446603338503117878
Segmentation fault: 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions