-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
IRGenLLVM IR generationLLVM IR generationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution
Description
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
Metadata
Metadata
Assignees
Labels
IRGenLLVM IR generationLLVM IR generationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution