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-4535] Compiler aborts due to segmentation fault with main.swift #47112

Closed
swift-ci opened this issue Apr 7, 2017 · 5 comments
Closed

[SR-4535] Compiler aborts due to segmentation fault with main.swift #47112

swift-ci opened this issue Apr 7, 2017 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code coverage Area → source tooling: code coverage compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 7, 2017

Previous ID SR-4535
Radar rdar://problem/31511957
Original Reporter renato (JIRA User)
Type Bug

Attachment: Download

Environment

macOS 10.12.4
Xcode 8.3 and 8.3.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: a7cc5edc3bf3ec5d3264bcfd23618762

Issue Description:

Problem

Compiler fails when running unit tests with a Segmentation fault: 11.

Such crash happens when both are true:

  • Code coverage is enabled (Gather coverage data option is enabled on the scheme)

  • A custom main.swift file is present to prevent loading the app delegate when running tests.

To be clear, if one disables the code coverage, tests run just fine.

main.swift

// main.swift
import UIKit

let argc = CommandLine.argc
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self,
                                                                      capacity: Int(CommandLine.argc))
let delegate = NSClassFromString("XCTestCase") == nil ? NSStringFromClass(AppDelegate.self) : nil
UIApplicationMain(argc, argv, nil, delegate)

How to reproduce

  1. Create a new empty project

  2. Enable code coverage

  3. Add main.swift with the code presented above

  4. Run unit tests

The attached project was created following these steps.

Stack Trace

0  swift                    0x000000010a4a5ec7 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x000000010a4a5376 SignalHandler(int) + 646
2  libsystem_platform.dylib 0x00007fffbd0a6b3a _sigtramp + 26
3  swift                    0x00000001082b1ddb swift::NewMangling::Mangler::addSubstitution(void const*) + 171
4  swift                    0x00000001082da585 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 917
5  swift                    0x00000001082dadea swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 378
6  swift                    0x00000001082da67f (anonymous namespace)::Traversal::doIt(swift::Decl*) + 1167
7  swift                    0x0000000107b57715 walkForProfiling(swift::Decl*, swift::ASTWalker&) + 629
8  swift                    0x0000000107b5c222 swift::Lowering::ProfilerRAII::ProfilerRAII(swift::Lowering::SILGenModule&, swift::Decl*) + 1538
9  swift                    0x0000000107ab1dcd swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 253
10 swift                    0x0000000107ab101b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
11 swift                    0x0000000107ab2bf9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
12 swift                    0x00000001072c4da2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42402
13 swift                    0x000000010727457c main + 9052
14 libdyld.dylib            0x00007fffbce97235 start + 1
@jckarter
Copy link
Member

jckarter commented Apr 7, 2017

@swift-ci create

@jckarter
Copy link
Member

jckarter commented Apr 7, 2017

Crashes when coverage is enabled. Does this look familiar, @eeckstein or @vedantk?

@jckarter
Copy link
Member

jckarter commented Apr 8, 2017

@slavapestov was going to look to see if there's an existing fix on master we can take for the 3.1 branch.

@vedantk
Copy link
Member

vedantk commented Apr 8, 2017

This is a likely dupe of SR-4453.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@hamishknight hamishknight added the code coverage Area → source tooling: code coverage label Sep 20, 2022
@hamishknight
Copy link
Collaborator

This is indeed a dupe of #47030

@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. code coverage Area → source tooling: code coverage 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

5 participants