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-11678] Assertion `Vars.empty() == VarLocs.empty() && "open ranges are inconsistent"' failed. #54087

Closed
benlangmuir opened this issue Oct 28, 2019 · 12 comments
Assignees
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 debug info Area → compiler → IRGen: Debug information emission

Comments

@benlangmuir
Copy link
Member

Previous ID SR-11678
Radar rdar://problem/56763405
Original Reporter @benlangmuir
Type Bug
Status Resolved
Resolution Done
Environment

Toolchain:
swift-DEVELOPMENT-SNAPSHOT-2019-10-24-a

OS:
macOS 10.15
Ubuntu 18.04 (docker image based on ubuntu1804:latest)

Source Code versions:
sourcekit-lsp: c051601d77512c5ca7394da280c57b0914ff9baa
indexstore-db: 363c7044cca2dd01724fa45bd602c89a129a1b23
llbuild: 0a778ca0c51025ffec95de881e59eb35c92f9944
swiftpm: 1ccff6203cbcd801211a27fd45c59a0b58775a3b

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, DebugInfo
Assignee @adrian-prantl
Priority Medium

md5: 1f0c943793d23c7a75fd7eb0e78b2680

Issue Description:

Compiling sourcekit-lsp with --sanitize=address asserts in the compiler.

$ swift build -c release --sanitize=address
Assertion failed: (Vars.empty() == VarLocs.empty() && "open ranges are inconsistent"), function empty, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/llvm/lib/CodeGen/LiveDebugValues.cpp, line 326.
Stack dump:
0.  Running pass 'Function Pass Manager' on module '/Users/blangmuir/src/lsp/sourcekit-lsp/.build/x86_64-apple-macosx/release/TSCUtility.build/ArgumentParser.swift.o'.
1.  Running pass 'Live DEBUG_VALUE analysis' on function '@"$s10TSCUtility7VersionV20unicodeScalarLiteralACSS_tcfCTf4gd_n"'
0  swift                    0x000000010b247aa5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010b246d55 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010b248088 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff73707b1d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000004b20 _sigtramp + 2358235168
5  libsystem_c.dylib        0x00007fff735dda1c abort + 120
6  libsystem_c.dylib        0x00007fff735dccd6 err + 0
7  swift                    0x000000010bc47bd3 (anonymous namespace)::LiveDebugValues::process(llvm::MachineInstr&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::SmallDenseMap<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u>, 4u, llvm::DenseMapInfo<llvm::MachineBasicBlock const*>, llvm::detail::DenseMapPair<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u> > >&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&, llvm::SmallVector<(anonymous namespace)::LiveDebugValues::TransferDebugPair, 4u>&, bool, llvm::DenseMap<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo>, llvm::SmallVector<llvm::DIExpression::FragmentInfo, 1u>, llvm::DenseMapInfo<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo> >, llvm::detail::DenseMapPair<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo>, llvm::SmallVector<llvm::DIExpression::FragmentInfo, 1u> > >&, llvm::DenseMap<llvm::DILocalVariable const*, llvm::SmallSet<llvm::DIExpression::FragmentInfo, 4u, std::__1::less<llvm::DIExpression::FragmentInfo> >, llvm::DenseMapInfo<llvm::DILocalVariable const*>, llvm::detail::DenseMapPair<llvm::DILocalVariable const*, llvm::SmallSet<llvm::DIExpression::FragmentInfo, 4u, std::__1::less<llvm::DIExpression::FragmentInfo> > > >&) (.cold.5) + 35
8  swift                    0x00000001097a576f (anonymous namespace)::LiveDebugValues::process(llvm::MachineInstr&, (anonymous namespace)::LiveDebugValues::OpenRangesSet&, llvm::SmallDenseMap<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u>, 4u, llvm::DenseMapInfo<llvm::MachineBasicBlock const*>, llvm::detail::DenseMapPair<llvm::MachineBasicBlock const*, llvm::SparseBitVector<128u> > >&, llvm::UniqueVector<(anonymous namespace)::LiveDebugValues::VarLoc>&, llvm::SmallVector<(anonymous namespace)::LiveDebugValues::TransferDebugPair, 4u>&, bool, llvm::DenseMap<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo>, llvm::SmallVector<llvm::DIExpression::FragmentInfo, 1u>, llvm::DenseMapInfo<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo> >, llvm::detail::DenseMapPair<std::__1::pair<llvm::DILocalVariable const*, llvm::DIExpression::FragmentInfo>, llvm::SmallVector<llvm::DIExpression::FragmentInfo, 1u> > >&, llvm::DenseMap<llvm::DILocalVariable const*, llvm::SmallSet<llvm::DIExpression::FragmentInfo, 4u, std::__1::less<llvm::DIExpression::FragmentInfo> >, llvm::DenseMapInfo<llvm::DILocalVariable const*>, llvm::detail::DenseMapPair<llvm::DILocalVariable const*, llvm::SmallSet<llvm::DIExpression::FragmentInfo, 4u, std::__1::less<llvm::DIExpression::FragmentInfo> > > >&) + 9711
9  swift                    0x00000001097a290e (anonymous namespace)::LiveDebugValues::runOnMachineFunction(llvm::MachineFunction&) + 7374
10 swift                    0x000000010981c36a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 330
11 swift                    0x000000010b08e830 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1040
12 swift                    0x000000010b08eb33 llvm::FPPassManager::runOnModule(llvm::Module&) + 131
13 swift                    0x000000010b08efce llvm::legacy::PassManagerImpl::run(llvm::Module&) + 910
14 swift                    0x00000001077c1b54 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 2548
15 swift                    0x00000001077c7ad4 (anonymous namespace)::LLVMCodeGenThreads::Thread::run() + 516
16 swift                    0x00000001077c78c9 (anonymous namespace)::LLVMCodeGenThreads::runThread(void*) + 9
17 libsystem_pthread.dylib  0x00007fff73712d36 _pthread_start + 125
18 libsystem_pthread.dylib  0x00007fff7370f58f thread_start + 15

$ swiftc -v
Apple Swift version 5.1.1-dev (Swift 35518d775c)
Target: x86_64-apple-darwin19.0.0

Source Code versions:
sourcekit-lsp: c051601d77512c5ca7394da280c57b0914ff9baa
indexstore-db: 363c7044cca2dd01724fa45bd602c89a129a1b23
llbuild: 0a778ca0c51025ffec95de881e59eb35c92f9944
swiftpm: 1ccff6203cbcd801211a27fd45c59a0b58775a3b

@benlangmuir
Copy link
Member Author

Only reproduces when optimization is enabled.

@belkadan
Copy link
Contributor

davidungar (JIRA User), one for you, right?

@benlangmuir
Copy link
Member Author

I have verified this still reproduces with the 10/28 toolchain. I have narrowed it down using the public toolchain: this builds OK with the 09-30-a toolchain, but crashes with the 10-03-a toolchain.

@swift-ci
Copy link
Collaborator

Comment by David Ungar (JIRA)

@belkadan Could you say more about the connection you see between this bug and my code? Thanks!

@belkadan
Copy link
Contributor

Ooops, I'm sorry, I thought this was the ASTScope source range stuff but instead it's the debug info source range stuff. My bad!

cc @dcci, @adrian-prantl

@adrian-prantl
Copy link
Member

Can you attach the LLVM IR that reproduces the crash when compiled with llc?

@dcci
Copy link
Mannequin

dcci mannequin commented Oct 31, 2019

I think @adrian-prantl very recently cc'ed an upstream commit in LiveDebugValues that fixed a crash. Maybe this is the same?

@adrian-prantl
Copy link
Member

@belkadan FYI the "ranges" here are variable location list ranges, i.e, the pc addresses for which a variable value is in a specific location.

@swift-ci
Copy link
Collaborator

Comment by David Ungar (JIRA)

Thanks, @belkadan . I do appreciate it when you ping me on these.

@benlangmuir
Copy link
Member Author

@swift-ci create

@adrian-prantl
Copy link
Member

Confirmed. It's the same bug that the cherry-pick was for.

@benlangmuir
Copy link
Member Author

For anyone following along, the commit in question was apple/llvm-project#57

@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 debug info Area → compiler → IRGen: Debug information emission
Projects
None yet
Development

No branches or pull requests

5 participants