Closed ematejska closed 3 years ago
Imported from JIRA https://bugs.swift.org/browse/TF-1112
main.swift
import TensorFlow let str = StringTensor("hello") print("str:", str) print("str.scalars:", str.scalars) print("str.array:", str.array)
$ /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-01-14-a.xctoolchain/usr/bin/swift main.swift str: StringTensor(handle: TensorFlow.TensorHandle<Swift.String>(handle: TensorFlow.TFETensorHandle)) str.scalars: [""] Fatal error: Division by zero: file /Users/swiftninjas/s4tf/build/buildbot_osx/swift-macosx-x86_64/stdlib/public/core/8/IntegerTypes.swift, line 13082 Stack dump: 0. Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-01-14-a.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 (Swift bf631dc2e4) 2. While running user code "main.swift" 0 swift 0x00000001045663e5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 swift 0x00000001045655f5 llvm::sys::RunSignalHandlers() + 85 2 swift 0x00000001045669d6 SignalHandler(int) + 278 3 libsystem_platform.dylib 0x00007fff655bdb5d _sigtramp + 29 4 libsystem_notify.dylib 0x00007fff655b435f notify_register_plain + 496 5 libswiftCore.dylib 0x000000010ccf7c87 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFySRys5UInt8VGXEfU_yAMXEfU_ + 87 6 libswiftCore.dylib 0x000000010ccf7953 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFySRys5UInt8VGXEfU_ + 99 7 libswiftCore.dylib 0x000000010ccf7579 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtF + 521 8 libswiftTensorFlow.dylib 0x000000010d5ce450 $s10TensorFlow20_ShapedArrayProtocolPA2aB7ElementRpzAD_ADQZAERSrlE11description9lineWidth04edgeF5Count11summarizingSSSi_SiSbtF + 1248 9 libswiftTensorFlow.dylib 0x000000010d5d54c8 $s10TensorFlow11ShapedArrayV11descriptionSSvg + 264 10 libswiftTensorFlow.dylib 0x000000010d5d54f8 $s10TensorFlow11ShapedArrayVyxGs23CustomStringConvertibleAAsAEP11descriptionSSvgTW + 24 11 libswiftCore.dylib 0x000000010cd77aee $ss15_print_unlockedyyx_q_zts16TextOutputStreamR_r0_lF + 766 12 libswiftCore.dylib 0x000000010ce088b2 $ss6_print_9separator10terminator2toySayypG_S2Sxzts16TextOutputStreamRzlFs7_StdoutV_Tg5Tm + 258 13 libswiftCore.dylib 0x000000010ce076b9 $ss5print_9separator10terminatoryypd_S2StFTm + 185 14 libswiftCore.dylib 0x000000010ce06e1f $ss5print_9separator10terminatoryypd_S2StF + 31 15 libswiftCore.dylib 0x000000010dd822c6 $ss5print_9separator10terminatoryypd_S2StF + 16233670 16 swift 0x00000001007e19c8 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 456 17 swift 0x00000001007e4a61 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 18 swift 0x00000001007d7b31 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&, swift::SILOptions const&) + 3457 19 swift 0x00000001007cd3c9 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, 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*) + 2697 20 swift 0x00000001007c1de6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 9318 21 swift 0x00000001007be9f3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5139 22 swift 0x000000010075a8ce main + 734 23 libdyld.dylib 0x00007fff653d23d5 start + 1 24 libdyld.dylib 0x000000000000000a start + 2596461622 Illegal instruction: 4
It seems the division here is causing crash: https://github.com/tensorflow/swift-apis/blob/fb164d1c236d4c82e5e4160ec3c0451bcadf9b1b/Sources/TensorFlow/Core/ShapedArray.swift#L341
(str.scalars == [""] is weird but it looks another bug.)
This is a duplicate of issue #638, which had already been created here, so I'll close this one to point at the more detailed target.
Imported from JIRA https://bugs.swift.org/browse/TF-1112
main.swift
It seems the division here is causing crash: https://github.com/tensorflow/swift-apis/blob/fb164d1c236d4c82e5e4160ec3c0451bcadf9b1b/Sources/TensorFlow/Core/ShapedArray.swift#L341
(str.scalars == [""] is weird but it looks another bug.)