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-10481] Conforming some objc classes to protocol crashes compiler if protocol is used in generic function #52881

Open
rnapier opened this issue Apr 13, 2019 · 2 comments
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 run-time crash Bug → crash: Swift code crashed during execution

Comments

@rnapier
Copy link

rnapier commented Apr 13, 2019

Previous ID SR-10481
Radar rdar://problem/49906866
Original Reporter @rnapier
Type Bug
Environment

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, IRGen, RunTimeCrash
Assignee None
Priority Medium

md5: 0237d5237749fa89fa6caace3d1c9141

Issue Description:

import Foundation
struct User: Decodable {}
protocol Transport {} 
struct X: Transport {}
// This line is key. Some types cause a crash; some do not.
// URLSession, NSObject, NSNumber – crash
// NSArray, NSProxy, URL, NSMeasurement – no crash
// Swift NSObject subclass – no crash
extension URLSession: Transport {}
// fetch must be generic over a restricted type (Decodable, Hashable both crash)
func fetch<Model: Decodable>(_ model: Model.Type, with transport: Transport) {}
// Note that X is passed here; a standard Swift struct unrelated to the objc type
fetch(User.self, with: X())

This leads to the following crash:

generic witness table at 0x10c1304b4 contains out-of-bounds requirement descriptor 0x10c1304ca
 Stack dump:
 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret x.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name x
 0 swift 0x0000000106ba6ee3 PrintStackTraceSignalHandler(void*) + 51
 1 swift 0x0000000106ba66bc SignalHandler(int) + 348
 2 libsystem_platform.dylib 0x00007fff70f80b5d _sigtramp + 29
 3 libsystem_platform.dylib 0x0000000000000004 _sigtramp + 2399663300
 4 libsystem_c.dylib 0x00007fff70e406a6 abort + 127
 5 libswiftCore.dylib 0x00007fff707b8ed5 swift::fatalError(unsigned int, char const*, ...) + 149
 6 libswiftCore.dylib 0x00007fff707c812a swift_getWitnessTable + 1994
 7 libswiftCore.dylib 0x00000001081672cc swift_getWitnessTable + 2543450476
 8 libswiftCore.dylib 0x00000001081670cd swift_getWitnessTable + 2543449965
 9 swift 0x000000010343e19d llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365
 10 swift 0x0000000103444572 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*) + 1090
 11 swift 0x0000000102a0d5d1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 58913
 12 swift 0x00000001029fb6de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
 13 swift 0x00000001029997be main + 1246
 14 libdyld.dylib 0x00007fff70d9b3d5 start + 1
 Abort trap: 6
@belkadan
Copy link
Contributor

It looks like this is only happening in the JIT. @jckarter, does this look familiar?

@jckarter
Copy link
Member

I haven't seen this before. @slavapestov might be more familiar with this part of the runtime.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
egorzhdan added a commit that referenced this issue Oct 10, 2022
egorzhdan added a commit that referenced this issue Dec 6, 2022
egorzhdan added a commit that referenced this issue Dec 6, 2022
egorzhdan added a commit that referenced this issue Dec 6, 2022
egorzhdan added a commit that referenced this issue Dec 6, 2022
egorzhdan added a commit that referenced this issue Dec 7, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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 run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

4 participants