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

Compiler crash with message "overlapping children" #78567

Closed
hjyamauchi opened this issue Jan 10, 2025 · 6 comments · Fixed by #78706 · May be fixed by #78719
Closed

Compiler crash with message "overlapping children" #78567

hjyamauchi opened this issue Jan 10, 2025 · 6 comments · Fixed by #78706 · May be fixed by #78719
Assignees
Labels
availability The @available attribute and availability checking in general bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software

Comments

@hjyamauchi
Copy link
Contributor

hjyamauchi commented Jan 10, 2025

Description

The compiler crashes with the following error message

error: compile command failed due to exception 3 (use -v to see invocation)
overlapping children
child 1:
(decl_implicit version=0 decl=eventsJSON src_range=[X.swift:139:13 - line:150:38])
child 2:
(decl_implicit version=0 decl=eventsJSON src_range=[X.swift:139:13 - line:150:38])
parent:
(decl_implicit version=0 decl=scheduleJSON src_range=[X.swift:138:9 - line:155:41]
  (decl_implicit version=0 decl=eventsJSON src_range=[X.swift:139:13 - line:150:38]  )
  (decl_implicit version=0 decl=eventsJSON src_range=[X.swift:139:13 - line:150:38]  ))
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.

Reproduction

% cat crash.swift
func test() {
    let m: [String: [String]] = [:]
    let _ = m.isEmpty ? "" : m.map { email, events in
        let bar: String = ""
        return bar
    }.joined(separator: ",")
}
% ~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/bin/swiftc   crash.swift
error: compile command failed due to signal 6 (use -v to see invocation)
overlapping children
child 1:
(decl_implicit version=15.0 decl=bar src_range=[crash.swift:4:9 - line:4:29])
child 2:
(decl_implicit version=15.0 decl=bar src_range=[crash.swift:4:9 - line:4:29])
parent:
(decl_implicit version=15.0 decl= src_range=[crash.swift:3:5 - line:6:29]
  (decl_implicit version=15.0 decl=bar src_range=[crash.swift:4:9 - line:4:29]  )
  (decl_implicit version=15.0 decl=bar src_range=[crash.swift:4:9 - line:4:29]  ))
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
% 

Stack dump

Stack dump:
0.	Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file crash.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/lib/swift -module-name crash -in-process-plugin-server-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/ww/kxcj3hm12kd92gcwr9t3y7k40000gq/T/TemporaryDirectory.OsJSYA/crash-1.o
1.	Apple Swift version 6.2-dev (LLVM 06a77c5cc0ff511, Swift f7fb0991b79fcda)
2.	Compiling with effective version 5.10
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           0x0000000106a42020 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106a40704 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106a4267c SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018fa1ae04 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018f9e3f70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018f8f0908 abort + 128
6  swift-frontend           0x00000001023192dc verificationError(swift::ASTContext&, llvm::StringRef, std::initializer_list<std::__1::pair<char const*, swift::AvailabilityScope const*>>) + 196
7  swift-frontend           0x0000000102319088 swift::AvailabilityScope::verify(swift::AvailabilityScope const*, swift::ASTContext&) const + 248
8  swift-frontend           0x0000000102318fe4 swift::AvailabilityScope::verify(swift::AvailabilityScope const*, swift::ASTContext&) const + 84
9  swift-frontend           0x00000001022cd308 swift::verify(swift::SourceFile&) + 132
10 swift-frontend           0x00000001025d9828 swift::TypeCheckSourceFileRequest::cacheResult(std::__1::tuple<>) const + 76
11 swift-frontend           0x000000010205eed0 swift::performTypeChecking(swift::SourceFile&) + 92
12 swift-frontend           0x0000000100e7e690 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_8>(long, swift::SourceFile&) + 16
13 swift-frontend           0x0000000100e77094 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
14 swift-frontend           0x0000000100e77028 swift::CompilerInstance::performSema() + 76
15 swift-frontend           0x0000000100c33eac withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
16 swift-frontend           0x0000000100c29ca4 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
17 swift-frontend           0x0000000100c294c0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2208
18 swift-frontend           0x00000001009dd2dc swift::mainEntry(int, char const**) + 3100
19 dyld                     0x000000018f664274 start + 2840

Expected behavior

No crash

Environment

A BCNY windows build compnerd.org Swift version 6.2-dev (LLVM 99b818a2e66f496, Swift ce3cc37e836693a)

Additional information

This doesn't fail with swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain but does with swift-DEVELOPMENT-SNAPSHOT-2024-11-19-a.xctoolchain. Likely broken between August and November 2024.

@hjyamauchi hjyamauchi added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels parser Area → compiler: The legacy C++ parser labels Jan 10, 2025
@compnerd compnerd added type checker Area → compiler: Semantic analysis and removed parser Area → compiler: The legacy C++ parser triage needed This issue needs more specific labels labels Jan 13, 2025
@compnerd
Copy link
Member

CC: @slavapestov

@hjyamauchi
Copy link
Contributor Author

I locally bisected this issue and it seems that this issue started with #76912 from October 2024. I built the toolchain at the following commits at which point this issue occurs and with cee810a0bcb0 Merge pull request #76912 from tshortli/sorted-type-refinement-contexts reverted on top of that it doesn't occur anymore, pointing this PR.

@tshortli Any thoughts?

  <project name="apple/swift-argument-parser" path="swift-argument-parser" remote="github" revision="0fbc8848e389af3bb55c182bc19ca9d5dc2f255b" sync-tags="false"/>
  <project name="apple/swift-asn1" path="swift-asn1" remote="github" revision="12c24ff59d541e5ef15116095445ce72b85cd0c6" sync-tags="false"/>
  <project name="apple/swift-atomics" path="swift-atomics" remote="github" revision="cd142fd2f64be2100422d658e7411e39489da985" sync-tags="false"/>
  <project name="apple/swift-certificates" path="swift-certificates" remote="github" revision="01d7664523af5c169f26038f1e5d444ce47ae5ff" sync-tags="false"/>
  <project name="apple/swift-collections" path="swift-collections" remote="github" revision="3d2dc41a01f9e49d84f0a3925fb858bed64f702d" sync-tags="false"/>
  <project name="apple/swift-corelibs-libdispatch" path="swift-corelibs-libdispatch" remote="github" revision="e85f6a0d5c9ea1f32f5013c3fa34e4fc146cd0eb" sync-tags="false"/>
  <project name="apple/swift-crypto" path="swift-crypto" remote="github" revision="629f0b679d0fd0a6ae823d7f750b9ab032c00b80" sync-tags="false"/>
  <project name="apple/swift-nio" path="swift-nio" remote="github" revision="b812b1b7318d0ad6863a2bc44752c077024fa0b8" sync-tags="false"/>
  <project name="apple/swift-system" path="swift-system" remote="github" revision="f9266c85189c2751589a50ea5aec72799797e471" sync-tags="false"/>
  <project name="compnerd/ds2" path="ds2" remote="github" revision="78743d5907df8f4cfd35a3fb6fd33f4570df8848" sync-tags="false"/>
  <project name="compnerd/swift-build" path="swift-build" remote="github" revision="abcedc85ee3b703488bccc0e03e96595b277bad1" sync-tags="false"/>
  <project name="compnerd/swift-win32" path="swift-win32" remote="github" revision="45a9e4e83cef6ffeef0509c34452d648e88d8eb6" sync-tags="false"/>
  <project name="curl/curl" path="curl" remote="github" revision="83bedbd730d62b83744cc26fa0433d3f6e2e4cd6" sync-tags="false"/>
  <project name="gnome/libxml2" path="libxml2" remote="github" revision="2b998a4ffbdfea04fc6a620721abc690a15743af" sync-tags="false"/>
  <project name="jpsim/Yams" path="Yams" remote="github" revision="0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3" sync-tags="false"/>
  <project name="madler/zlib" path="zlib" remote="github" revision="51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf" sync-tags="false"/>
  <project name="microsoft/mimalloc" path="mimalloc" remote="github" revision="8c532c32c3c96e5ba1f2283e032f69ead8add00f" sync-tags="false"/>
  <project name="swiftlang/indexstore-db" path="indexstore-db" remote="github" revision="6120b53b1e8774ef4e2ad83438d4d94961331e72" sync-tags="false"/>
  <project name="swiftlang/llvm-project" path="llvm-project" remote="github" revision="95f3fb07f8f52940912fdb0ba6f58fd0fe0f2511" sync-tags="false"/>
  <project name="swiftlang/sourcekit-lsp" path="sourcekit-lsp" remote="github" revision="3bf05ad51f84bb2c1922eb2df6d3b6bdcf080bc1" sync-tags="false"/>
  <project name="swiftlang/swift" path="swift" remote="github" revision="ee4d4a33bd2230fc41dd73ed2a719ff914851c77" sync-tags="false"/>
  <project name="swiftlang/swift-cmark" path="cmark" remote="github" revision="b022b08312decdc46585e0b3440d97f6f22ef703" sync-tags="false"/>
  <project name="swiftlang/swift-corelibs-foundation" path="swift-corelibs-foundation" remote="github" revision="e55e1d88001997be830fbc01086564431d405dad" sync-tags="false"/>
  <project name="swiftlang/swift-corelibs-xctest" path="swift-corelibs-xctest" remote="github" revision="a356762923b1ed2d4dcc8799a934bd87b54204af" sync-tags="false"/>
  <project name="swiftlang/swift-docc" path="swift-docc" remote="github" revision="79bb1d043960c3f4a884e0b9e085fae34777ca31" sync-tags="false"/>
  <project name="swiftlang/swift-docc-plugin" path="swift-docc-plugin" remote="github" revision="3303b164430d9a7055ba484c8ead67a52f7b74f6" sync-tags="false"/>
  <project name="swiftlang/swift-docc-render" path="swift-docc-render" remote="github" revision="0b380edfb7c4233c8744fff554c98debc55760eb" sync-tags="false"/>
  <project name="swiftlang/swift-docc-render-artifact" path="swift-docc-render-artifact" remote="github" revision="4d86d4231257092a7ea839bd2b91e86587e5e601" sync-tags="false"/>
  <project name="swiftlang/swift-docc-symbolkit" path="swift-docc-symbolkit" remote="github" revision="4c245d4b7264fbabb0fa1f7b3411c2c5bce4e2d9" sync-tags="false"/>
  <project name="swiftlang/swift-driver" path="swift-driver" remote="github" revision="2a49cfe813435a5ca1dd5ac1493d8b0b3a748e29" sync-tags="false"/>
  <project name="swiftlang/swift-experimental-string-processing" path="swift-experimental-string-processing" remote="github" revision="b5764ddad170bfccf5f0d0f28c12f2bc1dc21d91" sync-tags="false"/>
  <project name="swiftlang/swift-format" path="swift-format" remote="github" revision="d143a8a59c89aba5bdadf96787f7f41197ce6b71" sync-tags="false"/>
  <project name="swiftlang/swift-foundation" path="swift-foundation" remote="github" revision="002921d5e32b9bbea87545ce1cb08834cd7899ad" sync-tags="false"/>
  <project name="swiftlang/swift-foundation-icu" path="swift-foundation-icu" remote="github" revision="7e255a994ec26a08214f8fea2fdaf60b296e1f22" sync-tags="false"/>
  <project name="swiftlang/swift-installer-scripts" path="swift-installer-scripts" remote="github" revision="0724f4767c3b7c88cd4d7a86f7118dd7dc1115c6" sync-tags="false"/>
  <project name="swiftlang/swift-llbuild" path="llbuild" remote="github" revision="b7615e3762b5f29c57dc04a88d5f0ea259b9ec31" sync-tags="false"/>
  <project name="swiftlang/swift-lmdb" path="swift-lmdb" remote="github" revision="c42582487fe84f72a4d417dd2d8493757bd4d072" sync-tags="false"/>
  <project name="swiftlang/swift-markdown" path="swift-markdown" remote="github" revision="90a8e2ec3d814093435b76c5e87917bd81785fd4" sync-tags="false"/>
  <project name="swiftlang/swift-package-manager" path="swift-package-manager" remote="github" revision="58f9aa4484763108211a18bd669b8693fe5a170e" sync-tags="false"/>
  <project name="swiftlang/swift-syntax" path="swift-syntax" remote="github" revision="c00cc6a11620cf5c9c89e8ba4e0406140b15be41" sync-tags="false"/>
  <project name="swiftlang/swift-testing" path="swift-testing" remote="github" revision="0f37af26c46fd7919f8230c4f19ff9a97c0ce69f" sync-tags="false"/>
  <project name="swiftlang/swift-toolchain-sqlite" path="swift-toolchain-sqlite" remote="github" revision="a911e64716e2dbf7ebcedfa0299039eee9702e33" sync-tags="false"/>
  <project name="swiftlang/swift-tools-support-core" path="swift-tools-support-core" remote="github" revision="79f5ae380acea05a04415385303bd680e31bac93" sync-tags="false"/>

@tshortli tshortli added availability The @available attribute and availability checking in general and removed type checker Area → compiler: Semantic analysis labels Jan 14, 2025
@tshortli
Copy link
Contributor

#76912 introduced the verification step that's failing, so reverting that PR doesn't really tell us anything. The verification is meant to catch broken invariants in a data structure that is used by availability checking in the compiler. It looks like you've found a test case that reproduces an issue. I'll take a look, but in the meantime explicitly turning off AST verification or refactoring the code should be ways to work around it.

@tshortli tshortli self-assigned this Jan 14, 2025
@hjyamauchi
Copy link
Contributor Author

@tshortli Thanks for taking a look at this.
By "explicitly turning off AST verfication", do you mean, for example, merging a PR that temporarily comments out the the 3 lines here?

  // Verify the AvailabilityScope hierarchy.
  if (auto scope = SF.getAvailabilityScope()) {
    scope->verify(SF.getASTContext());
  }

@tshortli
Copy link
Contributor

No, sorry I should have elaborated. I meant by compiling with -disable-ast-verifier.

We shouldn't turn off a verifier entirely just because an example of code that fails verification exists. The verifier is only firing automatically because you are using a development toolchain.

tshortli added a commit to tshortli/swift that referenced this issue Jan 17, 2025
Since availability scopes may be built at arbitrary times, the builder may
encounter ASTs where SequenceExprs still exist and have not been folded, or it
may encounter folded SequenceExprs that have not been removed from the AST.

To avoid a double visit, track whether a SequenceExpr is folded and then
customize how ASTVisitor handles folded sequeneces.

Resolves rdar://142824799 and swiftlang#78567.
tshortli added a commit to tshortli/swift that referenced this issue Jan 17, 2025
Since availability scopes may be built at arbitrary times, the builder may
encounter ASTs where SequenceExprs still exist and have not been folded, or it
may encounter folded SequenceExprs that have not been removed from the AST.

To avoid a double visit, track whether a SequenceExpr is folded and then
customize how ASTVisitor handles folded sequences.

Resolves rdar://142824799 and swiftlang#78567.
@tshortli tshortli linked a pull request Jan 17, 2025 that will close this issue
@tshortli
Copy link
Contributor

Will be resolved by #78706.

tshortli added a commit to tshortli/swift that referenced this issue Jan 17, 2025
Since availability scopes may be built at arbitrary times, the builder may
encounter ASTs where SequenceExprs still exist and have not been folded, or it
may encounter folded SequenceExprs that have not been removed from the AST.

To avoid a double visit, track whether a SequenceExpr is folded and then
customize how ASTVisitor handles folded sequences.

Resolves rdar://142824799 and swiftlang#78567.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
availability The @available attribute and availability checking in general bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
3 participants