0

Previously working code now gets an error:

var row1 = simd_double3(x:CV1.x, y: CV1.y, z:CV1.z)
var row2 = simd_double3(x:CV2.x, y: CV2.y, z:CV2.z)
var row3 = simd_double3(x:self.n.x, y: self.n.y, z:self.n.z)
var m:simd_double3x3 = simd_double3x3(rows: [row1, row2, row3])
self.majorInvMatrix = m.inverse

The allocation of m.inverse gets

EXC_BAD_ACCESS(code=EXC_1386GPFLT)

Changing it to

let zz = m.inverse

still gives the error, but if I interrupt the code before the allocation and look at m.inverse in the console there isn't a problem.

If I add in the line var a = 2 there is no problem (it doesn't work with let a = 2)

var row1 = simd_double3(x:CV1.x, y: CV1.y, z:CV1.z)
var row2 = simd_double3(x:CV2.x, y: CV2.y, z:CV2.z)
var row3 = simd_double3(x:self.n.x, y: self.n.y, z:self.n.z)
var m:simd_double3x3 = simd_double3x3(rows: [row1, row2, row3])
var a = 2
self.majorInvMatrix = m.inverse
cbuchart
  • 10,847
  • 9
  • 53
  • 93
  • Did you make progress on this issue? I'm experiencing the same crashes using Xcode 11.3 on macOS 10.15.2. It seems related to using SIMD double matrices, I don't have issues so far using SIMD float matrices. It crashes when calling simd_double4x4.inverse. I've filed a radar with Apple. – Dr. F. Jan 09 '20 at 17:35
  • Sorry no. I just lived with a workaround of putting some other code in-between. When I assign new values to m I can get the inverse without needing any code in-between. – Neil Berry Jan 10 '20 at 18:18

1 Answers1

0

This is an operating system bug, or rather an OS library bug. In simple terms, the compiler and the SIMD library disagree about how the simd_double3x3 should be aligned in memory.

Your var a = 2 changes the alignment of things on the stack which is why it works (in your case - not mine, unfortunately).

The problem will be fixed in 10.15.4.

Full details on this thread:

https://forums.developer.apple.com/thread/127976

JeremyP
  • 84,577
  • 15
  • 123
  • 161