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

segfault in libdSFMT caused by unaligned Array #9037

Closed
rfourquet opened this issue Nov 17, 2014 · 0 comments
Closed

segfault in libdSFMT caused by unaligned Array #9037

rfourquet opened this issue Nov 17, 2014 · 0 comments
Labels
randomness Random number generation and the Random stdlib

Comments

@rfourquet
Copy link
Member

In 0f2d3ea, I incorrectly assumed that Julia Arrays are always 16-byte aligned (I misinterpreted this comment), which is not the case.
I can now see two ways to create a non-aligned Array, resize! (and functions calling jl_array_grow_end) and direct pointer manipulation:

a = Array(Float64, 0)
resize!(a, 1000)
Int(pointer(a)) % 16 # -> seems to be always 8 on my machine
rand!(a) # segfaults

and

a8 = Array(UInt8, 10000)
a = pointer_to_array(Ptr{Float64}(pointer(a8, 2)), 1000)
Int(pointer(a)) % 16 # -> 1
rand!(a) # segfaults
rfourquet added a commit that referenced this issue Nov 17, 2014
The rand!(::MersenneTwister, A::Array{Float64}) assumed that the
array A was 16-byte aligned, which can be false (e.g. after a call
to resize!) and lead to a segfault in libdSFMT.
JeffBezanson added a commit that referenced this issue Nov 20, 2014
fix #9037: segfault in libdSFMT caused by unaligned Array
bjarthur pushed a commit to bjarthur/julia that referenced this issue Nov 21, 2014
The rand!(::MersenneTwister, A::Array{Float64}) assumed that the
array A was 16-byte aligned, which can be false (e.g. after a call
to resize!) and lead to a segfault in libdSFMT.
@ViralBShah ViralBShah added the randomness Random number generation and the Random stdlib label Nov 22, 2014
waTeim pushed a commit to waTeim/julia that referenced this issue Nov 23, 2014
The rand!(::MersenneTwister, A::Array{Float64}) assumed that the
array A was 16-byte aligned, which can be false (e.g. after a call
to resize!) and lead to a segfault in libdSFMT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
randomness Random number generation and the Random stdlib
Projects
None yet
Development

No branches or pull requests

2 participants