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-5223] Runtime Crash: cannot init a class object #47798

Closed
swift-ci opened this issue Jun 14, 2017 · 8 comments
Closed

[SR-5223] Runtime Crash: cannot init a class object #47798

swift-ci opened this issue Jun 14, 2017 · 8 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-5223
Radar rdar://problem/32778104
Original Reporter victor.kinvey (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 4.0 / Xcode 9 Beta (9M136h)

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug, Miscompile, RunTimeCrash
Assignee victor.kinvey (JIRA)
Priority Medium

md5: 276f92a920ab172e822c18a4ee0d6b38

Issue Description:

import Foundation

protocol Person {
    
    init()
    
}

extension Person {
    
    static func newPerson() -> Self {
        return self.init()
    }
    
}

class Driver: NSObject, Person {
    
    required override init() {
        super.init()
    }
    
}

var driver = Driver.newPerson()
print(driver)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[Contents.Driver<0x1068de020> init]: cannot init a class object.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffaf5062cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffc433f48d objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffaf58817f +[NSObject(NSObject) init] + 127
    3   ???                                 0x00000001068dd26f 0x0 + 4404925039
    4   ???                                 0x00000001068dd295 0x0 + 4404925077
    5   ???                                 0x00000001068dd112 0x0 + 4404924690
    6   ???                                 0x00000001068dd052 0x0 + 4404924498
    7   swift                               0x000000010144f74f _ZN4llvm5MCJIT11runFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE + 655
    8   swift                               0x00000001014559b3 _ZN4llvm15ExecutionEngine17runFunctionAsMainEPNS_8FunctionERKNSt3__16vectorINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS8_ISA_EEEEPKPKc + 707
    9   swift                               0x0000000100862374 _ZL14performCompileRN5swift16CompilerInstanceERNS_18CompilerInvocationEN4llvm8ArrayRefIPKcEERiPNS_16FrontendObserverEPNS_20UnifiedStatsReporterE + 22532
    10  swift                               0x000000010085b304 _ZN5swift15performFrontendEN4llvm8ArrayRefIPKcEES3_PvPNS_16FrontendObserverE + 7332
    11  swift                               0x0000000100811728 main + 12248
    12  libdyld.dylib                       0x00007fffc4c24235 start + 1
    13  ???                                 0x000000000000000a 0x0 + 10
)
libc++abi.dylib: terminating with uncaught exception of type NSException
0  swift                    0x0000000103e8e3aa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000103e8d7e6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffc4e33b3a _sigtramp + 26
3  libsystem_platform.dylib 0x00000003cdb15240 _sigtramp + 147724064
4  libsystem_c.dylib        0x00007fffc4cb8420 abort + 129
5  libc++abi.dylib          0x00007fffc380e84a __cxa_bad_cast + 0
6  libc++abi.dylib          0x00007fffc3833c4f default_unexpected_handler() + 0
7  libobjc.A.dylib          0x00007fffc43416fe _objc_terminate() + 103
8  libc++abi.dylib          0x00007fffc3830d69 std::__terminate(void (*)()) + 8
9  libc++abi.dylib          0x00007fffc38307de __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
10 libobjc.A.dylib          0x00007fffc433f5b6 objc_exception_throw + 345
11 CoreFoundation           0x00007fffaf58817f +[NSObject(NSObject) init] + 127
12 CoreFoundation           0x00000001068dd26f +[NSObject(NSObject) init] + 1463112047
13 CoreFoundation           0x00000001068dd295 +[NSObject(NSObject) init] + 1463112085
14 CoreFoundation           0x00000001068dd112 +[NSObject(NSObject) init] + 1463111698
15 CoreFoundation           0x00000001068dd052 +[NSObject(NSObject) init] + 1463111506
16 swift                    0x000000010144f74f llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 655
17 swift                    0x00000001014559b3 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*) + 707
18 swift                    0x0000000100862374 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 22532
19 swift                    0x000000010085b304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
20 swift                    0x0000000100811728 main + 12248
21 libdyld.dylib            0x00007fffc4c24235 start + 1
22 libdyld.dylib            0x000000000000000a start + 993902038
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret Contents.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name Contents 
Abort trap: 6
@belkadan
Copy link
Contributor

Very strange. Thanks!

@belkadan
Copy link
Contributor

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by xuyecan (JIRA)

apparentsoft (JIRA User) Hope this bug can be fix as soon as possible![]( It cause a big trouble in my situation. Thanks)

@swift-ci
Copy link
Collaborator Author

Comment by Yasin Turkdogan (JIRA)

I have the very same problem.

@swift-ci
Copy link
Collaborator Author

Comment by Victor Barros (JIRA)

btw, crash still happening in Xcode 9 beta 3

@swift-ci
Copy link
Collaborator Author

Comment by Anthony Miller (JIRA)

I'm also experiencing this crash. Really hope this gets fixed before the GM Seed.

@jckarter
Copy link
Member

PR for master: #11107
PR for 4.0: #11108

@jckarter
Copy link
Member

Merged to swift-4.0-branch as 7c8958f. Should be fixed in future snapshots.

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

No branches or pull requests

4 participants