swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.58k stars 10.36k forks source link

(lib/SymbolGraphGen) DeclarationFragmentPrinter.h: Assertion `NumFragments' failed #71635

Open tayloraswift opened 8 months ago

tayloraswift commented 8 months ago

Description

we have again lost the ability to dump the symbol graph for the standard library

Reproduction

$ swift symbolgraph-extract -module-name _Concurrency -target x86_64-unknown-linux-gnu -minimum-access-level internal -output-dir .testing/swift/artifacts -emit-extension-block-symbols -skip-inherited-docs -pretty-print

Stack dump

swift-symbolgraph-extract: /home/ec2-user/swift/lib/SymbolGraphGen/DeclarationFragmentPrinter.h:140: virtual swift::symbolgraphgen::DeclarationFragmentPrinter::~DeclarationFragmentPrinter(): Assertion `NumFragments' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/bin/swift-symbolgraph-extract -module-name _Concurrency -target x86_64-unknown-linux-gnu -minimum-access-level internal -output-dir .testing/swift/artifacts -emit-extension-block-symbols -skip-inherited-docs -pretty-print
1.      Swift version 5.10-dev (LLVM dbfaba0078e9380, Swift 63c8b551eb2f613)
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):
/usr/bin/swift-symbolgraph-extract(+0x72e33f4)[0x55b3dbcba3f4]
/usr/bin/swift-symbolgraph-extract(+0x72e10ce)[0x55b3dbcb80ce]
/usr/bin/swift-symbolgraph-extract(+0x72e3768)[0x55b3dbcba768]
/lib64/libc.so.6(+0x54dd0)[0x7f0f30297dd0]
/lib64/libc.so.6(+0xa153c)[0x7f0f302e453c]
/lib64/libc.so.6(raise+0x16)[0x7f0f30297d26]
/lib64/libc.so.6(abort+0xd3)[0x7f0f3026b7f3]
/lib64/libc.so.6(+0x2871b)[0x7f0f3026b71b]
/lib64/libc.so.6(+0x4dcc6)[0x7f0f30290cc6]
/usr/bin/swift-symbolgraph-extract(+0x1c3914a)[0x55b3d661014a]
/usr/bin/swift-symbolgraph-extract(+0x1c40612)[0x55b3d6617612]
/usr/bin/swift-symbolgraph-extract(+0x1c3595d)[0x55b3d660c95d]
/usr/bin/swift-symbolgraph-extract(+0x1c378c9)[0x55b3d660e8c9]
/usr/bin/swift-symbolgraph-extract(+0x1c3fc7e)[0x55b3d6616c7e]
/usr/bin/swift-symbolgraph-extract(+0x1c32e30)[0x55b3d6609e30]
/usr/bin/swift-symbolgraph-extract(+0xceda1b)[0x55b3d56c4a1b]
/usr/bin/swift-symbolgraph-extract(+0x1c3272a)[0x55b3d660972a]
/usr/bin/swift-symbolgraph-extract(+0x1c323a7)[0x55b3d66093a7]
/usr/bin/swift-symbolgraph-extract(+0xd2030f)[0x55b3d56f730f]
/usr/bin/swift-symbolgraph-extract(+0xcc3a20)[0x55b3d569aa20]
/lib64/libc.so.6(+0x3feb0)[0x7f0f30282eb0]
/lib64/libc.so.6(__libc_start_main+0x80)[0x7f0f30282f60]
/usr/bin/swift-symbolgraph-extract(+0xcc1d85)[0x55b3d5698d85]
Aborted (core dumped)

Expected behavior

it worked in 5.9

Environment

Swift version 5.10-dev (LLVM dbfaba0078e9380, Swift 63c8b551eb2f613) Target: x86_64-unknown-linux-gnu

Additional information

the crash only occurs when using -minimum-access-level internal. this mode is required, even when the end goal is to only dump public symbols because of a separate issue where lib/SymbolGraphGen over-aggresively deletes nodes resulting in broken symbol graphs.

tayloraswift commented 8 months ago

_StringProcessing and Foundation are broken even on the public ACL:

$ swift symbolgraph-extract -module-name _StringProcessing -target x86_64-unknown-linux-gnu -minimum-access-level public -output-dir .testing/swift/artifacts -emit-extension-block-symbols -skip-inherited-docs

the crash seems to be related to -emit-extension-block-symbols rather than -minimum-access-level internal, as omitting that option also allows dumping the _Concurrency symbol graph.

tayloraswift commented 2 months ago

this crash is still taking place as of swift-6.0-DEVELOPMENT-SNAPSHOT-2024-07-24-a