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-10697] IRGen assertion failure when partially applying a generic function to a type whose conformance is not available locally #53094

Closed
marcrasi mannequin opened this issue May 16, 2019 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software IRGen LLVM IR generation

Comments

@marcrasi
Copy link
Mannequin

marcrasi mannequin commented May 16, 2019

Previous ID SR-10697
Radar rdar://problem/50853487
Original Reporter @marcrasi
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu 18.04. I got the same results with a few different toolchains from swift.org:

  • 4.2.4 Release

  • 5.0.1 Release

  • May 12, 2019 Trunk Snapshot

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, CompilerCrash, IRGen
Assignee @aschwaighofer
Priority Medium

md5: a7f7e56e10c504d4e143b513579e52af

blocks:

  • TF-507 Revert SR-10697 workaround for SimpleRNNCell in swift-apis
  • TF-922 Assertion failed: (lhs->getType() == rhs->getType() && "Adjoints must have equal types!")
  • TF-924 [AD] Control flow AD "Found use after free due to unvisited non lifetime ending uses?!"

relates to:

  • SR-12853 IRGen assertion failure: "(rootWTable && "root witness table not bound in local context!"), function emitArchetypeWitnessTableRef"

Issue Description:

protocol A {}

struct Wrapper<T> {}

extension Wrapper: A where T: A {}

func inner<T: A>(_ t: T) {}

func outer<T: A>(_ t: T) {
  let _: (Wrapper<T>) -> () = inner
}

Assertion failure while processing the `partial_apply` in `outer`. Reproducible only via swiftc sr-10697.swift, not via swift sr-10697.swift.

swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift/lib/IRGen/GenArchetype.cpp:245: llvm::Value *swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction &, swift::CanArchetypeType, swift::ProtocolDecl *): Assertion `rootWTable && "root witness table not bound in local context!"' failed.
Stack dump:
0.  Program arguments: /usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift -frontend -c -primary-file /usr/local/google/home/marcrasi/swift-base/build/Ninja-ReleaseAssert/swift-linux-x86_64/workspace/noadrepro.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name noadrepro -o /tmp/noadrepro-3b947f.o 
1.  Swift version 5.0-dev (LLVM 082dec2e22, Swift 87e1efd1a2)
2.  While emitting IR SIL function "@$s9noadrepro5outeryyxAA1ARzlF".
 for 'outer(_:)' (at /usr/local/google/home/marcrasi/swift-base/build/Ninja-ReleaseAssert/swift-linux-x86_64/workspace/noadrepro.swift:9:1)
 #&#8203;0 0x00000000044d6994 PrintStackTraceSignalHandler(void*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x44d6994)
 #&#8203;1 0x00000000044d45ee llvm::sys::RunSignalHandlers() (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x44d45ee)
 #&#8203;2 0x00000000044d6da8 SignalHandler(int) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x44d6da8)
 #&#8203;3 0x00007f139bd830c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
 #&#8203;4 0x00007f139a2c9fcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
 #&#8203;5 0x00007f139a2cb3fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
 #&#8203;6 0x00007f139a2c2e37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
 #&#8203;7 0x00007f139a2c2ee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
 #&#8203;8 0x000000000059ef93 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x59ef93)
 #&#8203;9 0x0000000000660436 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x660436)
#&#8203;10 0x0000000000663c73 bool llvm::function_ref<bool (unsigned int, swift::CanType, swift::ProtocolDecl*)>::callback_fn<emitConditionalConformancesBuffer(swift::irgen::IRGenFunction&, swift::ProtocolConformance const*)::$_15>(long, unsigned int, swift::CanType, swift::ProtocolDecl*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x663c73)
#&#8203;11 0x0000000000e1df01 swift::SILWitnessTable::enumerateWitnessTableConditionalConformances(swift::ProtocolConformance const*, llvm::function_ref<bool (unsigned int, swift::CanType, swift::ProtocolDecl*)>) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0xe1df01)
#&#8203;12 0x0000000000663911 emitWitnessTableAccessorCall(swift::irgen::IRGenFunction&, swift::ProtocolConformance const*, llvm::Value**) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x663911)
#&#8203;13 0x00000000006604a3 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6604a3)
#&#8203;14 0x000000000066108b swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::CanGenericSignature, swift::ModuleDecl&, swift::irgen::GenericRequirement, swift::SubstitutionMap) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x66108b)
#&#8203;15 0x00000000006662cd void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::EmitPolymorphicArguments::emit(swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&)::$_21>(long, swift::irgen::GenericRequirement) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6662cd)
#&#8203;16 0x0000000000666381 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&)::$_11>(long, swift::irgen::GenericRequirement) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x666381)
#&#8203;17 0x0000000000658618 swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x658618)
#&#8203;18 0x00000000006606cd swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6606cd)
#&#8203;19 0x000000000061b63c emitPartialApplicationForwarder(swift::irgen::IRGenModule&, llvm::Optional<swift::irgen::FunctionPointer> const&, bool, swift::irgen::Signature const&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap, swift::irgen::HeapLayout const*, llvm::ArrayRef<swift::ParameterConvention>) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x61b63c)
#&#8203;20 0x00000000006194cc swift::irgen::emitFunctionPartialApplication(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::FunctionPointer const&, llvm::Value*, swift::irgen::Explosion&, llvm::ArrayRef<swift::SILParameterInfo>, swift::SubstitutionMap, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::Explosion&, bool) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6194cc)
#&#8203;21 0x00000000006bc4d3 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6bc4d3)
#&#8203;22 0x00000000006abb05 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x6abb05)
#&#8203;23 0x00000000005dca8e swift::irgen::IRGenerator::emitGlobalTopLevel() (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x5dca8e)
#&#8203;24 0x000000000054ba83 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x54ba83)
#&#8203;25 0x000000000054c061 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x54c061)
#&#8203;26 0x00000000004d313e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x4d313e)
#&#8203;27 0x00000000004cee3e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x4cee3e)
#&#8203;28 0x0000000000473930 main (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x473930)
#&#8203;29 0x00007f139a2b72b1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#&#8203;30 0x000000000047357a _start (/usr/local/google/home/marcrasi/Downloads/swift-toolchains/head-nightly-2019-05-12/swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a-ubuntu18.04/usr/bin/swift+0x47357a)
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
@dan-zheng
Copy link
Collaborator

cc @belkadan: I'm pinging you because I noticed you edited the bug and added a rdar. 🙂
This bug is affecting the progress of the Swift for TensorFlow team: I wonder if an IRGen expert could please look into it? (maybe someone already is)

@belkadan
Copy link
Contributor

This got filed yesterday. I don't think that's really enough time for anyone to look at it.

@dan-zheng
Copy link
Collaborator

Related issue from 2018: SR-7287. It's been fixed, but the exact fix was not pinpointed.

@aschwaighofer
Copy link
Member

This should have been fixed by #30037 or #29912

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software IRGen LLVM IR generation
Projects
None yet
Development

No branches or pull requests

4 participants