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

[SR-15698] Published sink Abort 6 #4298

Open
swift-ci opened this issue Jan 7, 2022 · 1 comment
Open

[SR-15698] Published sink Abort 6 #4298

swift-ci opened this issue Jan 7, 2022 · 1 comment
Labels
bug Something isn't working LLDB for Swift swift

Comments

@swift-ci
Copy link

swift-ci commented Jan 7, 2022

Previous ID SR-15698
Radar None
Original Reporter Narumi.Inada (JIRA User)
Type Bug

Attachment: Download

Environment

2020 apple silicon MBP13"

macOS 12.0.1

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift, swift
Labels Bug
Assignee None
Priority Medium

md5: 971fb86c8a4de1e02452129125bde9e1

Issue Description:

Thank you for always helping me out. This is my first report.

I encountered a problem when I extends Published structure in Package.

Probably It is caused by calling sink(receiveValue🙂.

Which is available in playground but package cannot. I attached a package to reproduce it.

// Code to Reproduce. 

import Combine

extension String: Error {}


extension Published {
    func sinkIt() {
        var c = self
        var value: Value? = nil
        _ = c.projectedValue
            .combineLatest(Just(()))
            .sink {
                value = $0.0
            }
        print(value ?? "Thank you")
    }
}

Log:

narumiinada@CSM1 GenericUtils % swift test
Stored value type does not match pointer operand type!
  store %TSq* %97, i8** %8, align 1, !dbg !117
 i8*in function $s7Combine9PublishedV2GUSeRzSERzlE6encode2toys7Encoder_p_tKF
<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
<unknown>:0: note: Broken function found, compilation aborted!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/Sources/GU/Codabilities/Published.swift" "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/Sources/GU/Codabilities/Skip.swift" "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/Sources/GU/GU.swift" -emit-module-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published~partial.swiftmodule" -emit-module-doc-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published~partial.swiftdoc" -emit-module-source-info-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published~partial.swiftsourceinfo" -emit-dependencies-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published.d" -emit-reference-dependencies-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published.swiftdeps" -target arm64-apple-macosx11.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -I "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug" -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/ModuleCache" -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -module-name GU -target-sdk-version 12.1.0 -parse-as-library -o "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/GU.build/Codabilities/Published.swift.o" -index-store-path "/Users/narumiinada/Desktop/Xcode Projects/Swift Packages/GenericUtils/.build/arm64-apple-macosx/debug/index/store" -index-system-modules
1.  Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
2.  
3.  Running pass 'Module Verifier' on function '@"$s7Combine9PublishedV2GUSeRzSERzlE6encode2toys7Encoder_p_tKF"'
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           0x0000000104f4f9c4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000104f4eacc llvm::sys::RunSignalHandlers() + 128
2  swift-frontend           0x0000000104f50004 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x00000001891244e4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018910d15c pthread_kill + 288
5  libsystem_c.dylib        0x000000018904a314 abort + 164
6  swift-frontend           0x0000000100cc3d24 PrettyStackTraceFrontend::~PrettyStackTraceFrontend() + 0
7  swift-frontend           0x0000000104eb3154 llvm::report_fatal_error(llvm::Twine const&, bool) + 260
8  swift-frontend           0x0000000104eb3050 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
9  swift-frontend           0x0000000104e54af8 void llvm::VerifierSupport::CheckFailed<llvm::Instruction*, llvm::MDNode const*>(llvm::Twine const&, llvm::Instruction* const&, llvm::MDNode const* const&) + 0
10 swift-frontend           0x0000000104df8c44 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1164
11 swift-frontend           0x0000000104df81a0 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 104
12 swift-frontend           0x0000000104dfea60 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 336
13 swift-frontend           0x000000010110afc8 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 1500
14 swift-frontend           0x000000010110bf04 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2516
15 swift-frontend           0x0000000100cce414 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 3184
16 swift-frontend           0x0000000100cc1574 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6520
17 swift-frontend           0x0000000100c1adf8 main + 932
18 dyld                     0x00000001073610f4 start + 520


error: fatalError
@swift-ci
Copy link
Author

swift-ci commented Jan 7, 2022

Comment by Narumi Inada (JIRA)

I had misunderstood that is caused by calling sink.
It was by capturing value in block in sink.

So I prepared generic placeholder class for workaround. This could compile it.

But still I'm not sure why it is available only in playground.

import Combine

extension String: Error {}

final class PlaceHolder<Value> { var value: Value? }

extension Published {
    func sinkIt() {
        var c = self
        var holder: PlaceHolder<Value> = .init()
        _ = c.projectedValue
            .combineLatest(Just(()))
            .sink {
                holder.value = $0.0
            }
        print(holder.value ?? "Thank you")
    }
}

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift swift
Projects
None yet
Development

No branches or pull requests

1 participant