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-6766] [AST] Assertion failed: (std::none_of(elts.begin(), elts.end(), [](ASTNode node) -> bool { return node.isNull(); }) && "null element in BraceStmt") #49315

Open
dcci mannequin opened this issue Jan 15, 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 newfuzz PlaygroundTransform

Comments

@dcci
Copy link
Mannequin

dcci mannequin commented Jan 15, 2018

Previous ID SR-6766
Radar None
Original Reporter @dcci
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, PlaygroundTransform, newfuzz
Assignee None
Priority Medium

md5: 45ab1b7273f99ca3251a546a9d24e6d5

Issue Description:

cmdline:

$ /Users/davide/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file main.swift -pc-macro

code:

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: cp %s %t/main.swift
// RUN: %target-build-swift -Xfrontend -pc-macro -o %t/main %S/Inputs/PCMacroRuntime.swift %t/main.swift
// RUN: %target-run %t/main | %FileCheck %s
// RUN: %target-build-swift -Xfrontend -pc-macro -Xfrontend -playground -Xfrontend -debugger-support -o %t/main %S/Inputs/PCMacroRuntime.swift %t/main.swift %S/Inputs/SilentPlaygroundsRuntime.swift
// RUN: %target-run %t/main | %FileCheck %s
// REQUIRES: executable_test

// FIXME: rdar://problem/30234450 PCMacro tests fail on linux in optimized mode
// UNSUPPORTED: OS=linux-gnu

#sourceLocation(file: "main.swift", line: 8)
for i in 0..<3 /* comments won't confuse pc macro! */ {
  i // check it is hitting the loop conditional between each iteration.
}
// CHECK: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after
// CHECK-NEXT: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after
// CHECK-NEXT: [8:1-8:15] pc before
// CHECK-NEXT: [8:1-8:15] pc after
// CHECK-NEXT: [9:3-9:4] pc before
// CHECK-NEXT: [9:3-9:4] pc after

for i in 0..<3 { // comments here shouldn't confuse it
  i
  continue // checking it includes the continue
}
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after
// CHECK-NEXT: [24:1-24:15] pc before
// CHECK-NEXT: [24:1-24:15] pc after
// CHECK-NEXT: [25:3-25:4] pc before
// CHECK-NEXT: [25:3-25:4] pc after
// CHECK-NEXT: [26:3-26:11] pc before
// CHECK-NEXT: [26:3-26:11] pc after

for i in 0..<3 {
  i
  break // check it only happens once and includes the break
}
// CHECK-NEXT: [47:1-47:15] pc before
// CHECK-NEXT: [47:1-47:15] pc after
// CHECK-NEXT: [48:3-48:4] pc before
// CHECK-NEXT: [48:3-48:4] pc after
// CHECK-NEXT: [49:3-49:8] pc before
// CHECK-NEXT: [49:3-49:8] pc after
1
// check the file is finished
// CHECK-NEXT: [57:1-57:2] pc before
// CHECK-NEXT: [57:1-57:2] pc after
@dcci
Copy link
Mannequin Author

dcci mannequin commented Jan 15, 2018

stack trace:

Assertion failed: (std::none_of(elts.begin(), elts.end(), [](ASTNode node) -> bool { return node.isNull(); }) && "null element in BraceStmt"), function create, file /Users/davide/swift/
swift/lib/AST/Stmt.cpp, line 145.
0  swift                    0x000000010b41ac48 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010b41b356 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff63331f5a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2630672576
4  libsystem_c.dylib        0x00007fff6315c312 abort + 127
5  libsystem_c.dylib        0x00007fff63124368 basename_r + 0
6  swift                    0x000000010904079b swift::BraceStmt::create(swift::ASTContext&, swift::SourceLoc, llvm::ArrayRef<swift::ASTNode>, swift::SourceLoc, llvm::Optional<bool>) + 7
15
7  swift                    0x0000000108c5b6bd (anonymous namespace)::Instrumenter::prependLoggerCall(swift::BraceStmt*, swift::SourceRange) + 333
8  swift                    0x0000000108c5ca76 (anonymous namespace)::Instrumenter::transformStmt(swift::Stmt*) + 1078
9  swift                    0x0000000108c5af1f (anonymous namespace)::Instrumenter::transformBraceStmt(swift::BraceStmt*, bool) + 1375
10 swift                    0x0000000108c5a657 swift::performPCMacro(swift::SourceFile&, swift::TopLevelContext&)::ExpressionFinder::walkToDeclPre(swift::Decl*) + 487
11 swift                    0x0000000108f78039 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 185
12 swift                    0x0000000108f77f6b swift::Decl::walk(swift::ASTWalker&) + 27
13 swift                    0x0000000108c5a44b swift::performPCMacro(swift::SourceFile&, swift::TopLevelContext&) + 91
14 swift                    0x000000010899c3b0 swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift:
:TypeCheckingFlags, unsigned int>) + 512
15 swift                    0x000000010899b134 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 772
16 swift                    0x000000010899a977 swift::CompilerInstance::performSema() + 567
17 swift                    0x0000000107e9078c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::U
nifiedStatsReporter*) + 1628
18 swift                    0x0000000107e8f087 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3191
19 swift                    0x0000000107e4ea73 main + 3075
20 libdyld.dylib            0x00007fff630b0115 start + 1
Stack dump:
0.      Program arguments: /Users/davide/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file /Users/davide/swift/build/Ninja-RelWithDebInfoAs
sert/swift-macosx-x86_64/test-macosx-x86_64/PCMacro/Output/for.swift.tmp/main.swift -pc-macro
Abort trap: 6

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

No branches or pull requests

1 participant