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-12045] Swift 5.2 stops at assert "Function already has a profiler" #54481

Closed
HeEAaD opened this issue Jan 17, 2020 · 3 comments
Closed

[SR-12045] Swift 5.2 stops at assert "Function already has a profiler" #54481

HeEAaD opened this issue Jan 17, 2020 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@HeEAaD
Copy link

HeEAaD commented Jan 17, 2020

Previous ID SR-12045
Radar rdar://problem/58861159
Original Reporter @HeEAaD
Type Bug
Status Resolved
Resolution Done
Environment
  • swift-5.2-DEVELOPMENT-SNAPSHOT-2020-01-14-a.xctoolchain (Apple Swift version 5.2-dev (Swift 3cec742))
  • Xcode 11.3.1
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee @vedantk
Priority Medium

md5: 8cf3417de276dd19a1deafaf609e3e6c

Issue Description:

When compiling the following snippet with arguments "-frontend -c -profile-generate" the Swift 5.2 compiler stops at the "Function already has a profiler" assert.

struct Foo {
  var a = false
  let b = {
    false
  }()
}

Steps to reproduce

#

echo "struct Foo { var a = false; let b = { false }() }" > Foo.swift

#

/Library/Developer/Toolchains/swift-5.2-DEVELOPMENT-SNAPSHOT-2020-01-14-a.xctoolchain/usr/bin/swift -frontend -c -primary-file Foo.swift -profile-generate
  1. You will see the following stacktrace

Stacktrace

Assertion failed: (!Profiler && "Function already has a profiler"), function createProfiler, file /Users/buildnode/jenkins/workspace/oss-swift-5.2-package-osx/swift/lib/SIL/SILFunction.cpp, line 161.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.2-DEVELOPMENT-SNAPSHOT-2020-01-14-a.xctoolchain/usr/bin/swift -frontend -c -primary-file Foo.swift -profile-generate 
1.  Apple Swift version 5.2-dev (Swift 3cec7426cc)
2.  While silgen emitConstructor SIL function "@$s3FooAAV1aABSb_tcfC".
 for 'init(a:)' (at Foo.swift:1:8)
0  swift                    0x000000010428d625 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010428c835 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010428dc16 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff65c3442d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000004e80 _sigtramp + 2587691632
5  libsystem_c.dylib        0x00007fff65b09a1c abort + 120
6  libsystem_c.dylib        0x00007fff65b08cd6 err + 0
7  swift                    0x00000001044d7153 swift::SILFunction::createProfiler(swift::ASTNode, swift::SILDeclRef, swift::ForDefinition_t) (.cold.1) + 35
8  swift                    0x0000000100e2c1a9 swift::SILFunction::createProfiler(swift::ASTNode, swift::SILDeclRef, swift::ForDefinition_t) + 57
9  swift                    0x0000000100905462 setUpForProfiling(swift::SILDeclRef, swift::SILFunction*, swift::ForDefinition_t) + 210
10 swift                    0x0000000100904ecb swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 219
11 swift                    0x0000000100906f7d swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 77
12 swift                    0x000000010092af55 (anonymous namespace)::SILGenApply::visitAbstractClosureExpr(swift::AbstractClosureExpr*) + 37
13 swift                    0x000000010092c4a2 (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 2738
14 swift                    0x0000000100913550 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 144
15 swift                    0x000000010097136c swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 92
16 swift                    0x0000000100964370 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 32
17 swift                    0x00000001009481ad swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 9229
18 swift                    0x000000010090d9cf swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_3::operator()(swift::SILFunction*) const + 287
19 swift                    0x0000000100905d40 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 1184
20 swift                    0x00000001009e1883 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 515
21 swift                    0x00000001009df60b (anonymous namespace)::SILGenType::emitType() + 379
22 swift                    0x00000001009df489 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
23 swift                    0x000000010090a743 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 915
24 swift                    0x000000010090b646 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 230
25 swift                    0x000000010090ba86 swift::performSILGeneration(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions&) + 38
26 swift                    0x000000010060d12b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8379
27 swift                    0x000000010060a0e3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5139
28 swift                    0x00000001005a60ce main + 734
29 libdyld.dylib            0x00007fff65a3b7fd start + 1
[1]    83512 abort       -frontend -c -primary-file Foo.swift -profile-generate
@beccadax
Copy link
Contributor

@swift-ci create

@vedantk
Copy link
Member

vedantk commented Jan 28, 2020

Fixed in #29482

@HeEAaD
Copy link
Author

HeEAaD commented Jan 31, 2020

Thank you Vedant. I can confirm that this issue is fixed in swift-5.2-DEVELOPMENT-SNAPSHOT-2020-01-29-a.xctoolchain .

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

No branches or pull requests

3 participants