Skip to content

[SR-15181] A default value of Void() for an argument triggers an assertion failure on generating debug symbols #57504

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

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

Comments

@BradLarson
Copy link
Contributor

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

md5: 76521cafbc87c7e5766c3168ca608eaa

Issue Description:

Starting with the 08-29-2021 nightly snapshot (the 08-28-2021 nightly did not exhibit this), the following simple function:

func crasher(arg: Any = Void()) {}

placed by itself in a file triggers the assertion failure of "(Range.isValid() && "range should be valid"), function extractText, file SourceLoc.cpp, line 229" when generating debug symbols (swiftc -g file.swift).

As mentioned above, this appears to have happened at some point between the 08-28-2021 and 08-29-2021 nightly snapshots, but I have not yet isolated this further.

The full stack trace is as follows:

Assertion failed: (Range.isValid() && "range should be valid"), function extractText, file SourceLoc.cpp, line 229.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-09-08-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file VoidArgumentCrasher.swift -emit-module-path /var/folders/1s/z_s04yq55wq2jvgqghm8zm7w0000gp/T/TemporaryDirectory.gvk5b2/VoidArgumentCrasher-2.swiftmodule -emit-module-doc-path /var/folders/1s/z_s04yq55wq2jvgqghm8zm7w0000gp/T/TemporaryDirectory.gvk5b2/VoidArgumentCrasher-2.swiftdoc -emit-module-source-info-path /var/folders/1s/z_s04yq55wq2jvgqghm8zm7w0000gp/T/TemporaryDirectory.gvk5b2/VoidArgumentCrasher-2.swiftsourceinfo -target x86_64-apple-macosx11.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -color-diagnostics -g -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-09-08-a.xctoolchain/usr/bin/swift-driver -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-09-08-a.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -module-name VoidArgumentCrasher -target-sdk-version 11.3.0 -o /var/folders/1s/z_s04yq55wq2jvgqghm8zm7w0000gp/T/TemporaryDirectory.gvk5b2/VoidArgumentCrasher-2.o
1.  Apple Swift version 5.6-dev (LLVM ca88d53176e346a, Swift 8e4054f47465745)
2.  Compiling with the current language version
3.  While evaluating request ExecuteSILPipelineRequest(Run pipelines { non-Diagnostic Enabling Mandatory Optimizations, Serialization, Rest of Onone } on SIL for VoidArgumentCrasher)
4.  While running pass #​9 SILModuleTransform "SerializeSILPass".
5.  While serializing 'arg' (at VoidArgumentCrasher.swift:2:14)
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           0x000000010f8b54c7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010f8b46e5 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010f8b5d16 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff204c0d7d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000005508 _sigtramp + 18446603339974330280
5  libsystem_c.dylib        0x00007fff203d0411 abort + 120
6  libsystem_c.dylib        0x00007fff203cf7e8 err + 0
7  swift-frontend           0x000000010fea3293 swift::SourceManager::extractText(swift::CharSourceRange, llvm::Optional<unsigned int>) const (.cold.1) + 35
8  swift-frontend           0x000000010c3473c6 swift::SourceManager::extractText(swift::CharSourceRange, llvm::Optional<unsigned int>) const + 246
9  swift-frontend           0x000000010c16d35c swift::extractInlinableText(swift::SourceManager&, swift::ASTNode, llvm::SmallVectorImpl<char>&) + 428
10 swift-frontend           0x000000010c0265c3 swift::ParamDecl::getDefaultValueStringRepresentation(llvm::SmallVectorImpl<char>&) const + 707
11 swift-frontend           0x000000010b4baf21 swift::serialization::Serializer::DeclSerializer::visitParamDecl(swift::ParamDecl const*) + 177
12 swift-frontend           0x000000010b4a1b9a swift::serialization::Serializer::writeASTBlockEntity(swift::Decl const*) + 506
13 swift-frontend           0x000000010b4a340e bool swift::serialization::Serializer::writeASTBlockEntitiesIfNeeded<swift::serialization::Serializer::ASTBlockRecordKeeper<swift::Decl const*, llvm::PointerEmbeddedInt<unsigned int, 31>, 2u> >(swift::serialization::Serializer::ASTBlockRecordKeeper<swift::Decl const*, llvm::PointerEmbeddedInt<unsigned int, 31>, 2u>&) + 126
14 swift-frontend           0x000000010b4a32cc swift::serialization::Serializer::writeAllDeclsAndTypes() + 3068
15 swift-frontend           0x000000010b4a4c49 swift::serialization::Serializer::writeAST(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>) + 4153
16 swift-frontend           0x000000010b4aedac swift::serialization::Serializer::writeToStream(llvm::raw_ostream&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SILModule const*, swift::SerializationOptions const&, swift::fine_grained_dependencies::SourceFileDepGraph const*) + 972
17 swift-frontend           0x000000010b4f653f bool llvm::function_ref<bool (llvm::raw_pwrite_stream&)>::callback_fn<swift::serialize(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*, swift::fine_grained_dependencies::SourceFileDepGraph const*)::$_10>(long, llvm::raw_pwrite_stream&) + 95
18 swift-frontend           0x000000010aefc5c3 void llvm::function_ref<void (llvm::raw_pwrite_stream&)>::callback_fn<swift::withOutputFile(swift::DiagnosticEngine&, llvm::StringRef, llvm::function_ref<bool (llvm::raw_pwrite_stream&)>)::'lambda'(llvm::raw_pwrite_stream&)>(long, llvm::raw_pwrite_stream&) + 19
19 swift-frontend           0x000000010c33176d swift::atomicallyWritingToFile(llvm::StringRef, llvm::function_ref<void (llvm::raw_pwrite_stream&)>) + 1373
20 swift-frontend           0x000000010aefc503 swift::withOutputFile(swift::DiagnosticEngine&, llvm::StringRef, llvm::function_ref<bool (llvm::raw_pwrite_stream&)>) + 83
21 swift-frontend           0x000000010b4af525 swift::serialize(llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*, swift::fine_grained_dependencies::SourceFileDepGraph const*) + 245
22 swift-frontend           0x000000010aefc44c std::__1::__function::__func<performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*)::$_23, std::__1::allocator<performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*)::$_23>, void ()>::operator()() + 316
23 swift-frontend           0x000000010b0e5b54 swift::SILModule::serialize() + 36
24 swift-frontend           0x000000010b9c1504 SerializeSILPass::run() + 164
25 swift-frontend           0x000000010b8682f1 swift::SILPassManager::runModulePass(unsigned int) + 689
26 swift-frontend           0x000000010b86e89a swift::SILPassManager::execute() + 634
27 swift-frontend           0x000000010b864a08 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
28 swift-frontend           0x000000010b864991 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 65
29 swift-frontend           0x000000010b88570d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
30 swift-frontend           0x000000010b870de1 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 241
31 swift-frontend           0x000000010b864c42 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 82
32 swift-frontend           0x000000010b873868 swift::runSILPassesForOnone(swift::SILModule&) + 72
33 swift-frontend           0x000000010b043e88 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 248
34 swift-frontend           0x000000010aefb6a1 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 625
35 swift-frontend           0x000000010aefacc5 performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 693
36 swift-frontend           0x000000010aeefcb2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4850
37 swift-frontend           0x000000010aeb8142 swift::mainEntry(int, char const**) + 546
38 libdyld.dylib            0x00007fff20496f5d start + 1
@typesanitizer
Copy link

It looks like this is fixed on main, are you still seeing this issue?

@BradLarson
Copy link
Contributor Author

theindigamer (JIRA User) - I still had seen it this morning with last night's nightly Swift.org toolchain (the Sept. 14 one), but hadn't built one newer than that yet. This does only happen with `swiftc -g`, not plain `swiftc`, in case you'd tried the latter. I can try with a newer build, though.

@typesanitizer
Copy link

Apologies, I think I must've been looking at a stale build, I do see this crash after rebuilding from main.

@swift-ci create

@hamishknight
Copy link
Contributor

#39522

@hamishknight
Copy link
Contributor

Should be fixed by the above PR, please verify using the next available developer snapshot

@BradLarson
Copy link
Contributor Author

After trying out the latest nightly on projects impacted by this, I can confirm that it is fixed via the above. Thanks for the quick fix!

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

No branches or pull requests

3 participants