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-8738] Project doesn't compile with Incremental compilation, something about ObjC protocols #51247

Open
ScottRobbins opened this issue Sep 13, 2018 · 14 comments
Labels
access control Feature → modifiers: Access control and access levels 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 regression swift 4.2

Comments

@ScottRobbins
Copy link

Previous ID SR-8738
Radar None
Original Reporter @ScottRobbins
Type Bug

Attachment: Download

Environment

Macbook Pro (15-inch, 2017)

Xcode 10 GM Seed (happened in previous betas also)

Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug, 4.2Regression, CompilerCrash
Assignee None
Priority Medium

md5: ff400f05e75867ea10fd1cf9909ccc5a

relates to:

  • SR-8006 Segmentation fault: 11 (when whole module enabled)
  • SR-8540 Xcode 10 Beta 6 Swift 4.2 compiler crash

Issue Description:

For all of the betas, we have been unable to build our project using Xcode 10. It always results in a compiler crash:

`illegal instruction: 4`

It has a stack trace like:

```

0 swift 0x00000001078a564a PrintStackTraceSignalHandler(void*) + 42

1 swift 0x00000001078a4dfe SignalHandler(int) + 302

2 libsystem_platform.dylib 0x00007fff76a38f5a _sigtramp + 26

3 libsystem_platform.dylib 0x0000000100e4ee2f _sigtramp + 2319539951

4 swift 0x0000000103bd441a swift::irgen::ClangTypeConverter::convert(swift::irgen::IRGenModule&, swift::CanType) + 394

5 swift 0x0000000103bd69ea (anonymous namespace)::GenClangType::visitBoundGenericType(swift::CanTypeWrapper<swift::BoundGenericType>) + 650

6 swift 0x0000000103bd441a swift::irgen::ClangTypeConverter::convert(swift::irgen::IRGenModule&, swift::CanType) + 394

7 swift 0x0000000103ca1348 getObjCEncodingForTypes(swift::irgen::IRGenModule&, swift::SILType, llvm::ArrayRef<swift::SILParameterInfo>, llvm::StringRef, unsigned long long, bool) + 88

8 swift 0x0000000103ca108e getObjCEncodingForMethodType(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 414

9 swift 0x0000000103ca0d4e swift::irgen::emitObjCMethodDescriptorParts(swift::irgen::IRGenModule&, swift::AbstractFunctionDecl*, bool, bool, llvm::Constant*&, llvm::Constant*&, llvm::Constant*&) + 286

10 swift 0x0000000103bdf275 (anonymous namespace)::ClassDataBuilder::buildMethodList(llvm::ArrayRef<(anonymous namespace)::ClassDataBuilder::MethodDescriptor>, llvm::StringRef) + 949

11 swift 0x0000000103be4536 swift::irgen::emitObjCProtocolData(swift::irgen::IRGenModule&, swift::ProtocolDecl*) + 1766

12 swift 0x0000000103c9fb2f swift::irgen::IRGenModule::emitLazyObjCProtocolDefinitions() + 63

13 swift 0x0000000103d13e45 swift::irgen::IRGenModule::finalize() + 325

14 swift 0x0000000103cf8658 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) + 1960

15 swift 0x0000000103b38a10 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 46928

16 swift 0x0000000103b29dc5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717

17 swift 0x0000000103acfa35 main + 1349

18 libdyld.dylib 0x00007fff7672a015 start + 1

```

If whole module optimization is turned on, the project seems to compile fine.

Unfortunately I cannot attach my project and have so far been unable to reproduce in a test project.

@ScottRobbins
Copy link
Author

Writing notes as i test things. It seems that I can delete the contents of the file that it throws this issue for compiling and it still gives a compilation error for the file. Also, if i remove the reference from Xcode and re-add it, it still results in the same compile error for that file.

Deleting the file and creating a new file with the same name still results in a compilation error. Moving the file's location did not affect whether or not the compilation error occurred for that file.

@ScottRobbins
Copy link
Author

I seem to consistently get the same number of files have compilation errors if i delete derived data before building. If I don't delete derived data, that number can change, and sometimes some of those files will compile successfully.

None of this makes any sense to me, hopefully it will to someone else 😛

@belkadan
Copy link
Contributor

That part's just how incremental builds work in Xcode 10. Files are compiled in batches, and in some cases information is emitted to all files in a batch.

@belkadan
Copy link
Contributor

Some possibly related Radars, for Apple people picking this up: rdar://problem/40949298&41430307&43406595

@belkadan
Copy link
Contributor

Ah, if you download a development snapshot (for master, not 4.2) there should be a bit more info in the build log. https://swift.org/download/#snapshots

@ScottRobbins
Copy link
Author

Using that I now get a couple errors. Now it fails with: "Segmentation fault: 11"

The stack trace looks like:

2. While walking into decl 'FailingFileContainerViewController' at /Users/scottrobbins/Projects/ios/path/to/the/file/FailingFileContainerViewController.swift:1:1

0 swift 0x0000000105ee6288 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40

1 swift 0x0000000105ee5515 llvm::sys::RunSignalHandlers() + 85

2 swift 0x0000000105ee6892 SignalHandler(int) + 258

3 libsystem_platform.dylib 0x00007fff76a38f5a _sigtramp + 26

4 libsystem_platform.dylib 0x00007fb77f5f7000 _sigtramp + 146530496

5 swift 0x00000001030d3b23 (anonymous namespace)::IndexSwiftASTWalker::startEntity(swift::Decl*, swift::index::IndexSymbol&, bool) + 371

6 swift 0x00000001030d1d3f (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 1119

7 swift 0x000000010308cf49 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1209

8 swift 0x000000010365937b (anonymous namespace)::Traversal::doIt(swift::Decl*) + 171

9 swift 0x00000001036592bb swift::Decl::walk(swift::ASTWalker&) + 27

10 swift 0x00000001037124ca swift::SourceFile::walk(swift::ASTWalker&) + 170

11 swift 0x000000010308b249 swift::SourceEntityWalker::walk(swift::SourceFile&) + 201

12 swift 0x00000001030d1638 (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&, llvm::StringRef) + 248

13 swift 0x00000001030d1494 swift::index::indexSourceFile(swift::SourceFile*, llvm::StringRef, swift::index::IndexDataConsumer&) + 500

14 swift 0x00000001030da2a9 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1657

15 swift 0x00000001030d9c1a swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 298

16 swift 0x000000010248fb3c emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 284

17 swift 0x000000010248ad5c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 15164

18 swift 0x00000001024861d4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2932

19 swift 0x000000010243b51d main + 685

20 libdyld.dylib 0x00007fff7672a015 start + 1

error: Segmentation fault: 11

(FailingFileContainerViewController is one of our classes)

The other error that shows up says: "Command CompileSwift failed with a nonzero exit code". No stack trace though, just the print out of what it ran.

Edit: If I comment out the code in that file, when i build they all complains about a different file, and so on.

All of these files so far seem to inherit from UIKit objects. (custom uiviewcontrollers, uitableviewcells, uiviews, etc)

@ScottRobbins
Copy link
Author

I get this same segmentation fault just by inheriting from a UIKit object in the attatched test project, however that error doesn't occur with the Xcode 10 toolchain, just the snapshot of master, so it may be unrelated.

@belkadan
Copy link
Contributor

Yeah, the indexing thing sounds like a different problem. Maybe try turning off "Enable Index-While-Building Functionality" in your build settings for now?

@ScottRobbins
Copy link
Author

I turned off "Enable Index-While-Building Functionality" as you suggested, and using the "Swift Development Snapshot 2018-09-10 (a)" the project successfully compiles.

@ScottRobbins
Copy link
Author

This still fails on Xcode 10.1 beta 1

@ScottRobbins
Copy link
Author

@belkadan , do you have any timeline as to when the fix on master could make it into an Xcode? And is there any further investigation you need?

@belkadan
Copy link
Contributor

Well, we don't know what fixed it on master, so if it's going to get into a release sooner than Swift 5 we'd have to track that down. Even then, it might not be a safe change to cherry-pick, but maybe we'd have a workaround, at least.

If you have free time, bisecting through master development snapshots to figure out when it was fixed would be helpful. Otherwise one of us will get to it at some point…unless we're close to the Swift 5 release by then.

@belkadan
Copy link
Contributor

(Note: I'm using "Swift 5" to mean "the next release that branches from master". As last spring showed, that might not actually be called "Swift 5".)

@ScottRobbins
Copy link
Author

This seems to be fixed in Swift 5, testing with Xcode 10.2 beta 1

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added regression swift 4.2 access control Feature → modifiers: Access control and access levels and removed 4.2 regression labels Nov 19, 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
access control Feature → modifiers: Access control and access levels 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 regression swift 4.2
Projects
None yet
Development

No branches or pull requests

3 participants