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-6216] Compiler crashes during Release build (regression from 8.3 to 9.x) #48768

Open
swift-ci opened this issue Oct 25, 2017 · 7 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 4.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6216
Radar None
Original Reporter Reitzig (JIRA User)
Type Bug
Environment

macOS 10.13 (17A405)
XCode 9.0; XCode 9.1 beta (9B46)

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

md5: 82209094ec4c5236c5e0ad48e53ac0e5

Issue Description:

Our project, which builds just fine with XCode 8.3 in both configurations, and with XCode 9.x in Debug configuration, causes the compiler under XCode 9.x to segfault on Release builds.

I can't share the code, of course, and don't even know where to start looking for narrowing it down. Please advise.

Here's the stack trace the 9.1 beta produces:

0  swift                    0x0000000103b16dba PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000103b161f6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fff58de7f5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007f8bb4386600 _sigtramp + 1532618432
4  swift                    0x0000000100e36f93 void llvm::function_ref<void (swift::CanType, swift::ProtocolConformanceRef)>::callback_fn<swift::SILCombiner::propagateConcreteTypeOfInitExistential(swift::FullApplySite, swift::WitnessMethodInst*)::$_5>(long, swift::CanType, swift::ProtocolConformanceRef) + 291
5  swift                    0x0000000100e3615a swift::SILCombiner::propagateConcreteTypeOfInitExistential(swift::FullApplySite, swift::ProtocolDecl*, llvm::function_ref<void (swift::CanType, swift::ProtocolConformanceRef)>) + 1018
6  swift                    0x0000000100e36e6a swift::SILCombiner::propagateConcreteTypeOfInitExistential(swift::FullApplySite, swift::WitnessMethodInst*) + 474
7  swift                    0x0000000100e2c6bc swift::SILVisitor<swift::SILCombiner, swift::SILInstruction*>::visit(swift::ValueBase*) + 20940
8  swift                    0x0000000100e271d3 swift::SILCombiner::doOneIteration(swift::SILFunction&, unsigned int) + 2131
9  swift                    0x0000000100e33ea4 (anonymous namespace)::SILCombine::run() + 708
10 swift                    0x0000000100ee0513 swift::SILPassManager::runOneIteration() + 5139
11 swift                    0x000000010060585b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 235
12 swift                    0x0000000100ee5513 swift::runSILOptimizationPasses(swift::SILModule&) + 3907
13 swift                    0x0000000100489713 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14323
14 swift                    0x00000001004846b4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
15 swift                    0x00000001004395d8 main + 12248
16 libdyld.dylib            0x00007fff58b67145 start + 1
17 libdyld.dylib            0x000000000000007c start + 2806615864
Stack dump:
0.    Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c [sources] -target i386-apple-ios10.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk -I /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Products/Release-iphonesimulator -F [dependencies] -g -import-underlying-module -module-cache-path /Users/dhtp/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 3 -D COCOAPODS -serialize-debugging-options -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/SecureMessaging-generated-files.hmap -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/SecureMessaging-own-target-headers.hmap -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/SecureMessaging-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/SecureMessaging-project-headers.hmap -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Products/Release-iphonesimulator/include -Xcc -I/Applications/Xcode8.2/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/libxml2 -Xcc -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/libresolv -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/DerivedSources/i386 -Xcc -I/Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/DerivedSources -Xcc -DCOCOAPODS=1 -Xcc -ivfsoverlay -Xcc /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/dhtp/Documents/hds-client-library/iOS/SecureMessaging -emit-module-doc-path /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/Objects-normal/i386/SecureMessaging.swiftdoc -serialize-diagnostics-path /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/Objects-normal/i386/ServerDelegates.dia -O -module-name SecureMessaging -emit-module-path /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/Objects-normal/i386/SecureMessaging.swiftmodule -emit-objc-header-path /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/Objects-normal/i386/SecureMessaging-Swift.h -emit-dependencies-path /Users/dhtp/Library/Developer/Xcode/DerivedData/SecureMessaging-afmjzgbitaedxrbkcnfuyeuwfoea/Build/Intermediates.noindex/SecureMessaging.build/Release-iphonesimulator/SecureMessaging.build/Objects-normal/i386/ServerDelegates.d -num-threads 4 -o [object files]
1.    While running pass #&#8203;255188 SILFunctionTransform ""Combine SIL Instructions via Peephole Optimization"" on SILFunction "@_T015SecureMessaging5CacheC3setyx_Sb9overwritetFAA4UserC_Tg5".
 for 'set(_:overwrite:)' at [file:line:col]

Needless to say, this is a showstopper for us.

@swift-ci
Copy link
Collaborator Author

Comment by Raphael (JIRA)

I tried to isolate the error by extracting the component the stack dump pointed at, but was unsuccessful (no segfault observed). If anybody has an idea which optimization I have to trigger and how, please advise.

@swift-ci
Copy link
Collaborator Author

Comment by Raphael (JIRA)

I note that the compiler (with default settings) runs significantly longer (before it segfaults) compared to successful Debug builds; apparently it encounters something in our code that's hard to optimize.

Without WMO, the compiler takes a long, long time, but eventually finishes successfully. Apparently it encounters something in our code that's hard to optimize.

Fun fact: after a successful built without WMO, builds with WMO finish successfully as well! Even after a clean and clean build folder, it still builds. What the ... ? Was the problem caused by an unclean build folder? Due to other regressions in 9.x, I switch between versions of XCode (8.3, 9.0, 9.1-beta), can they interfere with each other? I'm also regularly switching Git branches.

@belkadan
Copy link
Contributor

@eeckstein, any advice?

We're supposed to handle switching between Xcode versions without cleaning your build folder, but since it's such a rare configuration and people usually immediately try cleaning when they see a problem it's possible a bug snuck in and we wouldn't know about it.

@eeckstein
Copy link
Member

As a first step I propose that you compile with the latest swift 4.0 development snapshot (download from https://swift.org/download/#snapshots). This will probably give us a more descriptive error, because the snapshots are built with assertions.

@swift-ci
Copy link
Collaborator Author

Comment by Raphael (JIRA)

@belkadan Well, we have to release with 8.3 because 9.0 introduced regressions in Data and/or Security Framework (not sure where, still have to isolate it, it's nasty). I upgraded to 9.0 because, why not (and then found aforementioned issues). I have 9.1-beta to see what will be fixed.
So I wonder how rare multi-install configurations can possibly be.

And all that despite me working with AppCode as much as possible.

@eeckstein Thanks for the pointer. Unfortunately, I can't reproduce the issue with neither the 9.1 nor the snapshot toolchain right now. If I encounter segfaults again, I'll try to repro with the latest snapshot before reporting.

@belkadan
Copy link
Contributor

Sorry, I don't mean having multiple Xcodes is rare; I mean switching back and forth in the same project is rare. But maybe that impression is based on older updates, which were much more likely to be source-breaking. We'd still like to fix any of these issues if we can track them down.

(Glad to hear that we may have fixed this particular one, whatever it is, in 9.1.)

@eeckstein
Copy link
Member

We fixed a bug in exactly this component. So most likely this is the same issue

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 4.0
Projects
None yet
Development

No branches or pull requests

4 participants