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-7328] Compiler crash when inner func uses outer func argument as default argument #49876

Closed
kateinoigakukun opened this issue Apr 2, 2018 · 1 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

Comments

@kateinoigakukun
Copy link
Member

Previous ID SR-7328
Radar rdar://problem/39142814
Original Reporter @kateinoigakukun
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 63b654d457ea71b26aa9c57b6706a706

duplicates:

  • SR-2189 Nested function with local default value crashes

Issue Description:

Minimum code is here.

func bar(foo: Int) {
    func inner(arg: Int = foo) {}
    inner()
}
bar(foo: 3)

Crash log is here

Global is external, but doesn't have external or weak linkage!
i8* ()* @_T010inner_func3barySi3foo_tFACL_Sivau
<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
<unknown>:0: note: Broken module found, compilation aborted!
0  swift                    0x000000010852bffa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010852b3b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff68d2bf5a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2536325312
4  libsystem_c.dylib        0x00007fff68b56312 abort + 127
5  swift                    0x0000000104b828e7 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_0::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 519
6  swift                    0x00000001084e3658 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
7  swift                    0x00000001084e3539 llvm::report_fatal_error(char const*, bool) + 41
8  swift                    0x00000001084abc5c (anonymous namespace)::VerifierLegacyPass::doFinalization(llvm::Module&) + 204
9  swift                    0x0000000108453015 llvm::FPPassManager::doFinalization(llvm::Module&) + 53
10 swift                    0x0000000108458167 llvm::legacy::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 71
11 swift                    0x0000000104d2ba35 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 5125
12 swift                    0x0000000104d30a62 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 2738
13 swift                    0x0000000104d2da52 swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, llvm::GlobalVariable**) + 1746
14 swift                    0x0000000104b8d36b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 43643
15 swift                    0x0000000104b80e64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
16 swift                    0x0000000104b358b5 main + 18917
17 libdyld.dylib            0x00007fff68aaa115 start + 1
@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2018

With assertions:

Assertion failed: (!var->getDeclContext()->isLocalContext() && "not a global variable!"), function isGlobalLazilyInitialized, file /Volumes/Data/swift-public/swift/lib/SILGen/SILGenGlobalVariable.cpp, line 64.

1.  While emitting SIL for 'bar(foo:)' at <stdin>:1:1
2.  While silgen emitFunction SIL function "@$S4main3bar3fooySi_tF".
 for 'bar(foo:)' at <stdin>:1:1
3.  While silgen emitDefaultArgGenerator  SIL function "@$S4main3bar3fooySi_tF5innerL_3argySi_tFfA_".

@swift-ci create

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

No branches or pull requests

3 participants