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-7910] Crash with "Unexpected non-pointer generic struct type in imported Clang module!" (Illegal instruction: 4, Abort trap: 6) error #50445

Closed
niw opened this issue Jun 7, 2018 · 1 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

Comments

@niw
Copy link

niw commented Jun 7, 2018

Previous ID SR-7910
Radar rdar://problem/40879067
Original Reporter @niw
Type Bug
Status Resolved
Resolution Done
Environment

Reproducible on next Swift, tested on macOS 10.13.5 (17F77).

Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Apple Swift version 4.2-dev (LLVM c41d146806, Clang 5272858825, Swift 9e274fc8d3)
Target: x86_64-apple-darwin17.6.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter, CompilerCrash
Assignee None
Priority Medium

md5: 64ad03f48c48a055ead7606d5e90e1e5

Issue Description:

Swift crashes when using a block pointer in lightweight generics in Objective-C.

Test.h

@import Foundation;

NS_ASSUME_NONNULL_BEGIN

typedef void (^Block)(void);

@interface TestClass : NSObject
- (NSArray<Block> *)m;
@end

NS_ASSUME_NONNULL_END

Test.m

#import "Test.h"

@implementation TestClass
- (NSArray<Block> *)m
{
    return @[];
}
@end

Test.swift

class Dummy {
    func f(a: TestClass) {
        print(a.m) // This will crash Swift.
    }
}

Stacktrace:

Unexpected non-pointer generic struct type in imported Clang module!
UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-4.2-package-osx/swift/lib/IRGen/GenClangType.cpp:474!
0  swift                    0x0000000110077318 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000110076587 llvm::sys::RunSignalHandlers() + 39
2  swift                    0x0000000110077992 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff5c294f5a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000116489558 _sigtramp + 3122611736
5  libsystem_c.dylib        0x00007fff5c0321ae abort + 127
6  swift                    0x00000001100170a0 LLVMInstallFatalErrorHandler + 0
7  swift                    0x000000010c94ae0c (anonymous namespace)::GenClangType::visitBoundGenericType(swift::CanTypeWrapper<swift::BoundGenericType>) + 1036
8  swift                    0x000000010c9477f5 swift::CanTypeVisitor<(anonymous namespace)::GenClangType, clang::CanQual<clang::Type> >::visit(swift::CanType) + 261
9  swift                    0x000000010c947513 swift::irgen::ClangTypeConverter::convert(swift::irgen::IRGenModule&, swift::CanType) + 163
10 swift                    0x000000010c949101 swift::irgen::IRGenModule::getClangType(swift::SILType) + 49
11 swift                    0x000000010c922664 swift::irgen::Signature::getUncached(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>) + 276
12 swift                    0x000000010c9a719b swift::irgen::IRGenModule::getSignature(swift::CanTypeWrapper<swift::SILFunctionType>) + 107
13 swift                    0x000000010c9da19e swift::irgen::getObjCMethodCallee(swift::irgen::IRGenFunction&, swift::irgen::ObjCMethod const&, llvm::Value*, swift::irgen::CalleeInfo&&) + 126
14 swift                    0x000000010ca663ac (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 1148
15 swift                    0x000000010ca4da9c swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8204
16 swift                    0x000000010c960d2b swift::irgen::IRGenerator::emitLazyDefinitions() + 1051
17 swift                    0x000000010ca28706 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1414
18 swift                    0x000000010ca28c5e swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 94
19 swift                    0x000000010c8c312b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 15595
20 swift                    0x000000010c8be45d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3325
21 swift                    0x000000010c87a7ad main + 2317
22 libdyld.dylib            0x00007fff5bf86015 start + 1
23 libdyld.dylib            0x0000000000000045 start + 2751963185
@belkadan
Copy link
Contributor

Doug fixed this.

master: #17247
4.2: #17260
4.2 early branch: #17261

@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
Projects
None yet
Development

No branches or pull requests

3 participants