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-11039] Interpreter crash with some types and Codable #53428

Open
swift-ci opened this issue Jun 28, 2019 · 2 comments
Open

[SR-11039] Interpreter crash with some types and Codable #53428

swift-ci opened this issue Jun 28, 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 run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11039
Radar rdar://problem/49639321
Original Reporter jeff.huff (JIRA User)
Type Bug
Environment

$ swift --version

Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)

Target: x86_64-apple-darwin18.6.0

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

md5: c4e62080ddb495e4319ea2ab65f82714

Issue Description:

I had a more complicated set of classes, but finally narrowed it down to a type of Date? and trying to use JSONEncoder to encode a class with one property.

$ cat test-crash.swift 
import Foundation


public class TestClass: Codable {
    var startDate: Date?
}


let test = TestClass()


if let jsonData = try? JSONEncoder().encode(test), let json = String(data: jsonData, encoding: .utf8) {
    print(json)
}

$ swift test-crash.swift 
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret test-crash.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name main 
0  swift                    0x0000000114237ee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x00000001142376bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff5fc08b5d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffedfbfa0d0 _sigtramp + 2147423632
4  libobjc.A.dylib          0x00007fff5e25362f initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 187
5  libobjc.A.dylib          0x00007fff5e242690 lookUpImpOrForward + 228
6  libobjc.A.dylib          0x00007fff5e242114 _objc_msgSend_uncached + 68
7  libswiftFoundation.dylib 0x00007fff5f69490c $s10Foundation21__CharacterSetStorage33_45BFD3D387700B862E3A7353B97EF7EDLLCMaTm + 28
8  libswiftFoundation.dylib 0x00007fff5f660b57 $s10Foundation11JSONEncoderCMa + 23
9  libswiftFoundation.dylib 0x000000011990e08a $s10Foundation11JSONEncoderCMa + 3123369290
10 swift                    0x0000000110acf38d llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365
11 swift                    0x0000000110ad5762 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
12 swift                    0x000000011009e831 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 58929
13 swift                    0x000000011008c92e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
14 swift                    0x000000011002a9ce main + 1246
15 libdyld.dylib            0x00007fff5fa1d3d5 start + 1
Segmentation fault: 11

If you compile it with swiftc and run it, it works normally.

If you change the type of startDate to String? then it works normally running it with swift.

@belkadan
Copy link
Contributor

Still crashes in master with

Assertion failed: (dependentIvars->Count == numFields), function initObjCClass, file /Volumes/Data/swift-public/swift/stdlib/public/runtime/Metadata.cpp, line 2445.

@mikeash, we have a Radar for this already, right?

@mikeash
Copy link
Contributor

mikeash commented Jun 28, 2019

Yes, it's rdar://problem/49639321. I added it to this issue.

@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
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 run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

4 participants