Skip to content

[SR-554] Program crashes in Debug mode and Playground, runs fine in release mode #43171

@swift-ci

Description

@swift-ci
Previous ID SR-554
Radar None
Original Reporter Tiza (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, NotOptimizedOnly
Assignee None
Priority Medium

md5: 447e7fd5ba2b3e00e4d3ca1ea8255854

Issue Description:

Make an new project on Xcode 7.2 (7C68) for a Swift Command Line Tool. Run the program below in Debug Mode. Crashes with EXC_BAD_ACCESS within seconds. Crashes also in playground after a while. Runs fine in release mode and delivers correct results.

var total: Int64 = 0
var prim: Int64 = 0
var maxPeri: Int64 = 100

func newTri(s0:Int64, _ s1:Int64, _ s2: Int64) -> () {
    let p = s0 + s1 + s2
    if p <= maxPeri {
        prim += 1
        total += maxPeri / p
        newTri( s0 + 2*(-s1+s2), 2*( s0+s2) - s1, 2*( s0-s1+s2) + s2)
        newTri( s0 + 2*( s1+s2), 2*( s0+s2) + s1, 2*( s0+s1+s2) + s2)
        newTri(-s0 + 2*( s1+s2), 2*(-s0+s2) + s1, 2*(-s0+s1+s2) + s2)
    }
}
while maxPeri <= 1_000_000_000 {
    prim = 0
    total = 0
    newTri(3, 4, 5)
    print("Up to \(maxPeri) : \(total) triples \( prim) primitives.")
    maxPeri *= 10
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfnon-optimized onlyFlag: An issue whose reproduction requires non-optimized compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions