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-4553] Recursive generics causes runtime crash #47130

Closed
swift-ci opened this issue Apr 10, 2017 · 0 comments
Closed

[SR-4553] Recursive generics causes runtime crash #47130

swift-ci opened this issue Apr 10, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself runtime The Swift Runtime

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-4553
Radar None
Original Reporter ylin (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 3.0.2 and 3.1, OSX and Ubuntu 16.04

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

md5: e2897dbe16375302dc368ad8a232af74

duplicates:

  • SR-2549 [CRTP] Non-generic class inheriting from a generic class with Self as generic parameter locks execution

Issue Description:

Here is a short example:

class Super<T> {
}

class Child: Super<Child> {
}

_ = Child()

On OSX, this code will compile, but when executed, it will crash with this stack trace:

ylin@youming-mbpr:~/Desktop$ swift main.swift 
0  swift                    0x0000000107b5dec7 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x0000000107b5d376 SignalHandler(int) + 646
2  libsystem_platform.dylib 0x00007fffa7414b3a _sigtramp + 26
3  libsystem_platform.dylib 0x000000011442c978 _sigtramp + 1828814424
4  libdispatch.dylib        0x00007fffa71cf8ef dispatch_once_f + 92
5  libdispatch.dylib        0x000000010a0681d8 dispatch_once_f + 1659472197
6  libdispatch.dylib        0x000000010a068424 dispatch_once_f + 1659472785
7  libdispatch.dylib        0x000000010a0683c4 dispatch_once_f + 1659472689
8  libdispatch.dylib        0x00007fffa71cf8fc _dispatch_client_callout + 8
9  libdispatch.dylib        0x00007fffa71cf8b9 dispatch_once_f + 38
10 libdispatch.dylib        0x000000010a0681d8 dispatch_once_f + 1659472197
11 libdispatch.dylib        0x000000010a06801c dispatch_once_f + 1659471753
12 swift                    0x00000001054a5e2f llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 655
13 swift                    0x00000001054aba23 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
14 swift                    0x00000001049a8b09 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&) + 3385
15 swift                    0x000000010497eda4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 50596
16 swift                    0x000000010492c57c main + 9052
17 libdyld.dylib            0x00007fffa7205235 start + 1
18 libdyld.dylib            0x000000000000000a start + 1491054038
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret main.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name main 
Illegal instruction: 4

However, on Ubuntu 16.04, this code will compile, but when executed it will hang and the process will not return without CTRL+C.

I don't know if this kind of recursive generics is natively supported by Swift. If yes, then the code should not crash at runtime. If not, then the compiler should've caught this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

1 participant