Skip to content

Commit ac1722a

Browse files
committed
Fix SIGBUS in the random test on ARM.
We should be robust against non-16bytes aligned addresses but it still has to be naturally aligned.
1 parent ba3d210 commit ac1722a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/random.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,14 @@ let mt = MersenneTwister()
275275
a = Array(Float64, 0)
276276
resize!(a, 1000) # could be 8-byte aligned
277277
b = Array(Float64, 1000) # should be 16-byte aligned
278-
c8 = Array(UInt8, 8001)
279-
c = pointer_to_array(Ptr{Float64}(pointer(c8, 2)), 1000) # Int(pointer(c)) % 16 == 1
278+
c8 = Array(UInt64, 1000)
279+
pc8 = pointer(c8)
280+
if Int(pc8) % 16 == 0
281+
pc8 += 8 # Make sure pc8 is not 16-byte aligned
282+
# It still has to be 8-byte aligned since it is otherwise invalid
283+
# on certain architectures (e.g. ARM)
284+
end
285+
c = pointer_to_array(Ptr{Float64}(pc8), 1000) # Int(pointer(c)) % 16 == 8
280286

281287
for A in (a, b, c)
282288
srand(mt, 0)

0 commit comments

Comments
 (0)