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

Recent failures with byte alignment #6

Closed
sbromberger opened this issue May 30, 2017 · 2 comments
Closed

Recent failures with byte alignment #6

sbromberger opened this issue May 30, 2017 · 2 comments

Comments

@sbromberger
Copy link
Contributor

ERROR: LoadError: ArgumentError: reinterpret from alignment 1 bytes to alignment 4 bytes not allowed
Stacktrace:
 [1] reinterpret(::Type{UInt32}, ::Array{UInt8,1}, ::Tuple{Int64}) at ./array.jl:160
 [2] reinterpret(::Type{UInt32}, ::Array{UInt8,1}) at ./array.jl:139
 [3] include_from_node1(::String) at ./loading.jl:551
 [4] include(::String) at ./sysimg.jl:14
 [5] anonymous at ./<missing>:2
while loading /Users/seth/.julia/v0.7/JLD2/src/JLD2.jl, in expression starting on line 6

This appears to be all over the place via

const OBJECT_HEADER_SIGNATURE = reinterpret(UInt32, UInt8['O', 'H', 'D', 'R'])[1]
julia> versioninfo()
Julia Version 0.7.0-DEV.373
Commit 82e9638225 (2017-05-28 01:51 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin16.5.0)
  CPU: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)
@timholy
Copy link
Member

timholy commented May 30, 2017

I wrote a package that may help fix this: https://github.com/JuliaArrays/UnalignedVectors.jl. Consequence of JuliaLang/julia#21831.

@yuyichao
Copy link

FWIW, that line would be better written as

const OBJECT_HEADER_SIGNATURE = htol(0x5244484f) # "OHDR"

Or with a helper function that does the reverse reinterpret.

A lot of packages abuse reinterpret this way and we could have base function to do that instead of casting through arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants