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-14605] Optimized builds of Vapor trigger an addFragmentOffset assertion failure #56957

Closed
BradLarson opened this issue May 6, 2021 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@BradLarson
Copy link
Collaborator

Previous ID SR-14605
Radar rdar://problem/77673443
Original Reporter @BradLarson
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: ca549944019d2dff1175d78ad81570b8

Issue Description:

The popular Vapor web framework triggers an assertion failure during optimized builds on current nightly Swift snapshots, as well as with development toolchains for the Swift 5.5 release branch. This occurs in macOS and Ubuntu environments.

To reproduce, attempt to build the Vapor framework in a release configuration:

git clone https://github.com/vapor/vapor.git
cd vapor
swift build -c release

using a current nightly snapshot toolchain or current Swift 5.5 release branch toolchain. This will produce an assertion like the following:

Assertion failed: (FragmentOffset >= OffsetInBits && "overlapping or duplicate fragments"), function addFragmentOffset, file /Users/buildnode/jenkins/workspace/oss-swift-5.5-package-macos/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp, line 639.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Running pass 'Function Pass Manager' on module '/Users/larson/Development/PassiveLogic/vapor/.build/x86_64-apple-macosx/release/Vapor.build/Application.swift.o'.
1.  Running pass 'X86 Assembly Printer' on function '@"$s5Vapor13ClientRequestV7contentAA16ContentContainer_pvM.resume.0"'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001112fc1f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x00000001112fb3b5 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x00000001112fc816 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff2062cd7d _sigtramp + 29
4  swift-frontend           0x00000001140e76fa cmark_strbuf__initbuf + 209005
5  libsystem_c.dylib        0x00007fff2053b720 abort + 120
6  libsystem_c.dylib        0x00007fff2053a9d6 err + 0
7  swift-frontend           0x0000000111c64b33 llvm::DwarfExpression::addFragmentOffset(llvm::DIExpression const*) (.cold.1) + 35
8  swift-frontend           0x000000010e78dc9b llvm::DwarfExpression::addFragmentOffset(llvm::DIExpression const*) + 203
9  swift-frontend           0x000000010e764d64 llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&, bool) + 804
10 swift-frontend           0x000000010e7635a5 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImpl<llvm::DIE*>&, bool*) + 4853
11 swift-frontend           0x000000010e761d82 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImpl<llvm::DIE*>&) + 146
12 swift-frontend           0x000000010e763a9c llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImpl<llvm::DIE*>&, bool*) + 6124
13 swift-frontend           0x000000010e765835 llvm::DwarfCompileUnit::constructSubprogramScopeDIE(llvm::DISubprogram const*, llvm::LexicalScope*) + 117
14 swift-frontend           0x000000010e774807 llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) + 1111
15 swift-frontend           0x000000010e7579c0 llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) + 112
16 swift-frontend           0x000000010e73c03d llvm::AsmPrinter::emitFunctionBody() + 12381
17 swift-frontend           0x000000010dd700bc llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) + 300
18 swift-frontend           0x000000010f04df6d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 349
19 swift-frontend           0x000000011117faa2 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1202
20 swift-frontend           0x0000000111185c08 llvm::FPPassManager::runOnModule(llvm::Module&) + 72
21 swift-frontend           0x00000001111800d0 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1104
22 swift-frontend           0x000000010cd87130 swift::compileAndWriteLLVM(llvm::Module*, llvm::TargetMachine*, swift::IRGenOptions const&, swift::UnifiedStatsReporter*, swift::DiagnosticEngine&, llvm::raw_pwrite_stream&, llvm::sys::SmartMutex<false>*) + 416
23 swift-frontend           0x000000010cd86c5b swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 3451
24 swift-frontend           0x000000010cd924b9 (anonymous namespace)::LLVMCodeGenThreads::Thread::run() + 489
25 swift-frontend           0x000000010cd922c9 (anonymous namespace)::LLVMCodeGenThreads::runThread(void*) + 9
26 libsystem_pthread.dylib  0x00007fff205e8950 _pthread_start + 224
27 libsystem_pthread.dylib  0x00007fff205e447b thread_start + 15 

The root cause may be the same as with SR-13263, but this is occurring outside of a differentiable Swift context. This is a regression since at least the 1/19/2021 snapshot toolchains, but I have not narrowed down further as to when it was introduced. I also have not isolated the specific type or code that is triggering this within the Vapor project.

@typesanitizer
Copy link

@swift-ci create

@BradLarson
Copy link
Collaborator Author

At some point between when this was reported and the 2021-07-07 nightly (and latest 5.5 stable releases) this appears to have been fixed. Vapor now builds cleanly via `swift build -c release`, so I'll close this out.

@adrian-prantl
Copy link
Member

I confirmed that this is fixed by cherry-picking 19203f2 on top of

swift-DEVELOPMENT-SNAPSHOT-2021-05-29-a.

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

No branches or pull requests

3 participants