Skip to content

Segfault when unsafe_loading inbounds pointer #56265

Closed
@jakobnissen

Description

@jakobnissen

I'm not sure if this is expected behaviour, but I couldn't find any information about expected alignment in Julia.

Code to reproduce:

julia> using SIMD

julia> s = b"AAAAAAAAAAAAAABBBBBCBCBBBBBBBBCDE";

julia> foo(s) = GC.@preserve s unsafe_load(Ptr{Vec{32, UInt8}}(pointer(s)));

julia> foo(s)
[122821] signal 11 (128): Segmentation fault

I believe this may be a Julia bug, because SIMD doesn't add methods to unsafe_load.

Edit: Looks like the generated code changed between 1.10 and 1.11. In 1.11, it emits a vmovaps, which requires the pointer to be 16-byte aligned, which strings aren't always, whereas in 1.10, it emitted vmovups instead.

This is on Julia 1.11.1 and SIMD 3.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:codegenGeneration of LLVM IR and native coderegression 1.11Regression in the 1.11 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions