Swift 3 Xcode 8 beta 6 compile error

When I run the following code under RELEASE buid configuration,I got an error message

Accepted Reply

Now This issue has been verified as resolved and can be closed.You are so great.

Replies

0 swift 0x000000011117999d PrintStackTraceSignalHandler(void*) + 45

1 swift 0x00000001111793e6 SignalHandler(int) + 470

2 libsystem_platform.dylib 0x00007fff94c6852a _sigtramp + 26

3 libsystem_platform.dylib 0x00007fa3fb538797 _sigtramp + 1720517255

4 swift 0x000000010e8d0cbf hoistChecksInLoop(swift::DominanceInfo*, llvm::DomTreeNodeBase<swift::SILBasicBlock>*, ABCAnalysis&, InductionAnalysis&, swift::SILBasicBlock*, swift::SILBasicBlock*, swift::SILBasicBlock*) + 703

5 swift 0x000000010e8cf976 (anonymous namespace)::ABCOpt::run() + 14470

6 swift 0x000000010e8c3c8d swift::SILPassManager::runOneIteration() + 6077

7 swift 0x000000010e8c8e36 swift::runSILOptimizationPasses(swift::SILModule&) + 3462

8 swift 0x000000010e59141b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 20091

9 swift 0x000000010e58a2c5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029

10 swift 0x000000010e54788d main + 8685

11 libdyld.dylib 0x00007fff8c72d5ad start + 1


1. While running pass #13477 SILFunctionTransform "SIL Array bounds check optimization" on SILFunction "@_TFC11testcompile6iFrAMA16loadElementArrayfTGSaSf_GSaSf_4highGSaSf_3lowGSaSf_5closeGSaSf_6volumeGSaSf__T_".


Command failed due to signal: Segmentation fault: 11

import Foundation

import OpenGLES


class iFrAMA: NSObject{

var InpPeriodFrAMA:Int = 14

var InpShift:Int = 0

var FrAmaBuffer:[GLfloat] = []

override init() {

super.init()

}

convenience init(InpPeriodFrAMA:Int,InpShift:Int) {

self.init()

self.InpPeriodFrAMA = InpPeriodFrAMA

self.InpShift = InpShift

}

func loadElementArray(_ price: [GLfloat], _ open: [GLfloat], high: [GLfloat], low: [GLfloat], close: [GLfloat], volume: [GLfloat])

{

FrAmaBuffer = [GLfloat](repeating: 0.0,count: open.count)

let rates_total = open.count

if rates_total < 2*InpPeriodFrAMA

{return}

var limit:Int = 0

var Hi1:GLfloat = 0

var Hi2:GLfloat = 0

var Hi3:GLfloat = 0

var Lo1:GLfloat = 0

var Lo2:GLfloat = 0

var Lo3:GLfloat = 0

var N1:GLfloat = 0

var N2:GLfloat = 0

var N3:GLfloat = 0

var D:GLfloat = 0

var ALFA:GLfloat = 0

let prev_calculated:Int = 0

if prev_calculated==0

{

limit = 2*InpPeriodFrAMA-1;

for i in 0...limit

{

FrAmaBuffer[i]=price[i]

}

}



for i in limit..<rates_total

{

Hi1=iHighest(i,InpPeriodFrAMA,high)

Lo1=iLowest(i,InpPeriodFrAMA,low)

Hi2=iHighest(i-InpPeriodFrAMA,InpPeriodFrAMA,high)

Lo2=iLowest(i-InpPeriodFrAMA,InpPeriodFrAMA,low)

Hi3=iHighest(i,2*InpPeriodFrAMA,high)

Lo3=iLowest(i,2*InpPeriodFrAMA,low)

N1=(Hi1-Lo1)/GLfloat(InpPeriodFrAMA)

N2=(Hi2-Lo2)/GLfloat(InpPeriodFrAMA)

N3=(Hi3-Lo3)/GLfloat(2*InpPeriodFrAMA)

D=(log(N1+N2)-log(N3))/log(2.0)

ALFA=exp(-4.6*(D-1.0))

let item = FrAmaBuffer[i-1]

let last = (1-ALFA) * item

let value = ALFA * price[i] + last

FrAmaBuffer[i] = value

}

}

func iHighest(_ StartPos:Int, _ Depth:Int,_ High:[GLfloat]) -> GLfloat

{

var res:GLfloat = 0

if StartPos<0 || StartPos-Depth+1<0 || Depth<0

{

return 0.0

}

res = High[StartPos];

for i in StartPos-Depth+1..<StartPos

{

if High[i]>res

{

res = High[i]

}

}

return(res);

}

func iLowest(_ StartPos:Int, _ Depth:Int,_ Low:[GLfloat]) -> GLfloat

{

var res:GLfloat = 0

if StartPos<0 || StartPos-Depth+1<0 || Depth<0

{

return 0.0

}

res = Low[StartPos];

for i in StartPos-Depth+1..<StartPos

{

if Low[i]<res

{

res = Low[i]

}

}

return(res);

}

}

a. What platform?


b. What error?

This is actually the compiler crashing. In general the compiler shouldn’t crash regardless of what input you give it. Please file a bug about this; it’d be ideal if you could include the smallest possible test project that reproduces the crash.

Please post your bug number, just for the record.

As to what you can do about it right now, that’s hard to say. Frame 4 (

hoistChecksInLoop(***)
) implies that this is a problem with the optimisation of a loop. You could (temporarily) remove the loops from your code until you stop the crash, then try adding them back in, slightly tweaked, to see if you can prevent the crash.

I’ll admit that’s not much fun.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

0 swift 0x000000011117999d PrintStackTraceSignalHandler(void*) + 45

1 swift 0x00000001111793e6 SignalHandler(int) + 470

2 libsystem_platform.dylib 0x00007fff94c6852a _sigtramp + 26

3 libsystem_platform.dylib 0x00007fa3fb538797 _sigtramp + 1720517255

4 swift 0x000000010e8d0cbf hoistChecksInLoop(swift::DominanceInfo*, llvm::DomTreeNodeBase<swift::SILBasicBlock>*, ABCAnalysis&, InductionAnalysis&, swift::SILBasicBlock*, swift::SILBasicBlock*, swift::SILBasicBlock*) + 703

5 swift 0x000000010e8cf976 (anonymous namespace)::ABCOpt::run() + 14470

6 swift 0x000000010e8c3c8d swift::SILPassManager::runOneIteration() + 6077

7 swift 0x000000010e8c8e36 swift::runSILOptimizationPasses(swift::SILModule&) + 3462

8 swift 0x000000010e59141b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 20091

9 swift 0x000000010e58a2c5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029

10 swift 0x000000010e54788d main + 8685

11 libdyld.dylib 0x00007fff8c72d5ad start + 1


1. While running pass #13477 SILFunctionTransform "SIL Array bounds check optimization" on SILFunction "@_TFC11testcompile6iFrAMA16loadElementArrayfTGSaSf_GSaSf_4highGSaSf_3lowGSaSf_5closeGSaSf_6volumeGSaSf__T_".


Command failed due to signal: Segmentation fault: 11

You can copy the above code into a new project, run it under release configuration.You can see the problem.

Thank you for your advice。

I make a test project.You should change the build configuration to Release, and run it.


https://s3.amazonaws.com/swift3.xcode/testcompile.zip


The follow code cause the problem,I hope the xcode 8 release version can resolve the problem.Thank you

for i in limit..<rates_total

{

let Hi1=iHighest(i,InpPeriodFrAMA,high)

let Lo1=iLowest(i,InpPeriodFrAMA,low)

let Hi2=iHighest(i-InpPeriodFrAMA,InpPeriodFrAMA,high)

let Lo2=iLowest(i-InpPeriodFrAMA,InpPeriodFrAMA,low)

let Hi3=iHighest(i,2*InpPeriodFrAMA,high)

let Lo3=iLowest(i,2*InpPeriodFrAMA,low)

let N1=(Hi1-Lo1)/GLfloat(InpPeriodFrAMA)

let N2=(Hi2-Lo2)/GLfloat(InpPeriodFrAMA)

let N3=(Hi3-Lo3)/GLfloat(2*InpPeriodFrAMA)

let D=(log(N1+N2)-log(N3))/log(2.0)

let ALFA=exp(-4.6*(D-1.0))

let item = FrAmaBuffer[i-1]

let last = (1-ALFA) * item

let value = ALFA * price[i] + last

FrAmaBuffer[i] = value

}

I hope the xcode 8 release version can resolve the problem.

Did you file a bug about this? If so, what’s the bug number?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I'v post a bug just now.And the bug number is 28204253


Thanks

Now This issue has been verified as resolved and can be closed.You are so great.