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-7243] Fatal error compiling w/4.1 "Emergency spill slot is out of reach", with -Onone -Owholemodule #49791

Closed
e28eta mannequin opened this issue Mar 21, 2018 · 17 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 regression swift 4.1

Comments

@e28eta
Copy link
Mannequin

e28eta mannequin commented Mar 21, 2018

Previous ID SR-7243
Radar rdar://problem/38894780
Original Reporter @e28eta
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 9.3b4, Swift 4.1 snapshots

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

md5: c8c3a5b552ec5059a0e910a83dc4e7d0

is duplicated by:

  • SR-7350 Fatal error compiling w/4.1 "Incomplete scavenging after 2nd pass", with -Onone -Osinglefile

relates to:

  • SR-7479 "apply expression is not marked as throwing or non-throwing"

Issue Description:

Our swift project won't compile with the Swift 4.1 snapshots, using our debug configuration. I tried the Xcode 9.3b4 toolchain. It produced a bunch of warnings for deprecations, and then failed with Command failed due to signal: Abort trap: 6:

<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
<unknown>:0: note: Incomplete scavenging after 2nd pass
0  swift                    0x000000011096cffa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000011096c3b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff66b95f5a _sigtramp + 26
3  libsystem_platform.dylib 0x000070000902e270 _sigtramp + 2722726704
4  libsystem_c.dylib        0x00007fff669c0312 abort + 127
5  swift                    0x000000010cfc3dc7 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_0::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 519
6  swift                    0x0000000110924658 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
7  swift                    0x0000000110924539 llvm::report_fatal_error(char const*, bool) + 41
8  swift                    0x000000010f187354 llvm::scavengeFrameVirtualRegs(llvm::MachineFunction&, llvm::RegScavenger&) + 516
9  swift                    0x000000010f13ebb4 (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) + 9684
10 swift                    0x000000010f08fe26 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 134
11 swift                    0x00000001108947b1 llvm::FPPassManager::runOnFunction(llvm::Function&) + 449
12 swift                    0x00000001108943f3 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
13 swift                    0x000000011089ddb8 llvm::legacy::PassManager::run(llvm::Module&) + 1112
14 swift                    0x000000010d16d5c1 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 7409
15 swift                    0x000000010d1711bc ThreadEntryPoint(swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int) + 220
16 swift                    0x000000010d17120f void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int), swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int> >(void*) + 47
17 libsystem_pthread.dylib  0x00007fff66b9f6c1 _pthread_body + 340
18 libsystem_pthread.dylib  0x00007fff66b9f56d _pthread_body + 0
19 libsystem_pthread.dylib  0x00007fff66b9ec5d thread_start + 13
Stack dump:
0.  Running pass 'Function Pass Manager' on module '/Users/danj/Library/Developer/Xcode/DerivedData/Dashboard-bamvmgbmfutuzrdsiytphozanriy/Build/Intermediates.noindex/Dashboard.build/Debug-iphoneos/Dashboard.build/Objects-normal/arm64/CardViewModel+Transfer.o'.
1.  Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@_T09Dashboard14EventCellModelVACSg6Stripe0B0V5event_tcfC'

I then tried with swift-4.1-DEVELOPMENT-SNAPSHOT-2018-03-14-a, and it hits an assertion, presumably slightly earlier in the compilation process:

Assertion failed: ((!RS || !RS->isScavengingFrameIndex(FrameIndex)) && "Emergency spill slot is out of reach"), function eliminateFrameIndex, file /Users/buildnode/jenkins/workspace/oss-swift-4.1-package-osx/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp, line 402.
0  swift                    0x0000000108456be8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001084572f6 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff66b95f5a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000003450 _sigtramp + 2571556112
4  libsystem_c.dylib        0x00007fff669c0312 abort + 127
5  libsystem_c.dylib        0x00007fff66988368 basename_r + 0
6  swift                    0x00000001065e06e1 llvm::AArch64RegisterInfo::eliminateFrameIndex(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, int, unsigned int, llvm::RegScavenger*) const + 593
7  swift                    0x0000000106f83047 llvm::RegScavenger::spill(unsigned int, llvm::TargetRegisterClass const&, int, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) + 647
8  swift                    0x0000000106f83fd8 llvm::RegScavenger::scavengeRegisterBackwards(llvm::TargetRegisterClass const&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, bool, int) + 1544
9  swift                    0x0000000106f84d11 scavengeVReg(llvm::MachineRegisterInfo&, llvm::RegScavenger&, unsigned int, bool) + 465
10 swift                    0x0000000106f8476f scavengeFrameVirtualRegsInBlock(llvm::MachineRegisterInfo&, llvm::RegScavenger&, llvm::MachineBasicBlock&) + 415
11 swift                    0x0000000106f843bc llvm::scavengeFrameVirtualRegs(llvm::MachineFunction&, llvm::RegScavenger&) + 140
12 swift                    0x0000000106f39735 (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) + 10549
13 swift                    0x0000000106e702a4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 180
14 swift                    0x000000010833422d llvm::FPPassManager::runOnFunction(llvm::Function&) + 541
15 swift                    0x00000001083344a3 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
16 swift                    0x00000001083349fb llvm::legacy::PassManagerImpl::run(llvm::Module&) + 971
17 swift                    0x00000001050631fb swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 2699
18 swift                    0x000000010506825b ThreadEntryPoint(swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int) + 507
19 swift                    0x000000010506937f void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int), swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, int> >(void*) + 47
20 libsystem_pthread.dylib  0x00007fff66b9f6c1 _pthread_body + 340
21 libsystem_pthread.dylib  0x00007fff66b9f56d _pthread_body + 0
22 libsystem_pthread.dylib  0x00007fff66b9ec5d thread_start + 13
Stack dump:
0.  Running pass 'Function Pass Manager' on module '/Users/danj/Library/Developer/Xcode/DerivedData/Dashboard-bamvmgbmfutuzrdsiytphozanriy/Build/Intermediates.noindex/Dashboard.build/Debug-iphoneos/Dashboard.build/Objects-normal/arm64/CardViewModel+Transfer.o'.
1.  Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@_T09Dashboard14EventCellModelVACSg6Stripe0B0V5event_tcfC'

I am a little confused, because CardViewModel+Transfer.o and EventCellModel() aren't related, so I'm not sure where to start looking to minimize & reproduce.

It appears to only crash with -Onone -Owhole-module turned on: https://github.com/fastred/Optimizing-Swift-Build-Times#whole-module-optimization
The crash goes away with -Onone or with -Owhole-module.

Also, it does not crash with swift-DEVELOPMENT-SNAPSHOT-2018-03-14-a.xctoolchain

@belkadan
Copy link
Contributor

I'm afraid we're probably not going to be able to do much without a project. If you can't share it here, would you mind filing a Radar?

aschwaighofer@apple.com (JIRA User), do you know who's responsible for this area of LLVM at Apple, just in case they can psychic-debug it?

@aschwaighofer
Copy link
Member

I would try Matthias and/or Quentin.

@belkadan
Copy link
Contributor

Matthias identified this as similar to some other problems that were already fixed, but was not able to go further.

Dan: even if you can't give us the whole project, is there any chance you can give us the source of just the Dashboard.EventCellModel type and the init(event:) initializer?

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2018

Comment by Igor Silva (JIRA)

I'm also facing that issue on Xcode 9.3 (stable).

The only references to "Incomplete scavenging after 2nd pass" that I cant find online are the LLVM source code.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

Igor, are you able to share your project? We'd like to fix this but we'd be much more likely to find an answer if we have an example where it's reproducing.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

Dan's workarounds are likely to apply to you as well: turn on optimization or turn off whole-module mode.

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2018

Comment by Igor Silva (JIRA)

I cannot share the project, unfortunately (under NDA).

I'm trying other combinations of optimization level and compilation mode. I can confirm that it does crash with "Incomplete scavenging after 2nd pass" when using `-Onone` and `Single File`.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

Yikes. Thank you for testing, at least.

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2018

Comment by Igor Silva (JIRA)

It finally compiled with -O, and now I've got this error. Not sure if it's related.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

That sounds like your standard library doesn't match up with your compiler. Are you using plain Xcode 9.3 GM, or 9.3 GM plus a development toolchain, or what?

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2018

Comment by Igor Silva (JIRA)

Plain Xcode 9.3 GM, downloaded from Mac App Store.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

I'm afraid that's a new issue, then. But there's probably no point in filing it without your project. :-(

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

On the plus side for this issue, it turns out Apple LLVM engineers are already investigating it as rdar://problem/38894780 and some variants may have already been fixed in the master development snapshots.

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 3, 2018

Comment by Igor Silva (JIRA)

That's great to know @belkadan, thanks.

As a note, with Whole Module on, I've got the same issue (attached image, not the original one).

@belkadan
Copy link
Contributor

This should be fixed by now in master.

@swift-ci
Copy link
Collaborator

Comment by Justin Trantham (JIRA)

I am experiencing this same issue when building using Xcode Version 9.3.1 (9E501). Is this something that will be resolved in Xcode 9.4? When will Xcode 9.4 be release stable? Would you advise to use the beta version temporarily? Thanks

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

No branches or pull requests

4 participants