Skip to content

segmentation fault (out of bounds error) when using BitIntegers.jl #167

Description

@lampretl

After starting julia -t 12 --check-bounds=yes I run:

julia> using Random, BitIntegers, Polyester

julia> @define_integers 24;

julia> function f!(x,p) @batch for i=1:length(x) x[i] = p[x[i]] end end;

julia> n=10^6;  p=randperm(n);  x=UInt24.(rand(1:n,10^8));  @assert all(1≤v≤n for v∈x);

julia> f!(x,p)
ERROR: BoundsError: attempt to access 1000000-element StrideArraysCore.PtrArray{Int64, 1, (1,), Tuple{Int64}, Tuple{Nothing}, Tuple{Static.StaticInt{1}}} at index [4235520]
Stacktrace:
  [1] throw_boundserror(A::StrideArraysCore.PtrArray{Int64, 1, (1,), Tuple{Int64}, Tuple{Nothing}, Tuple{Static.StaticInt{1}}}, I::Tuple{Int64})
    @ Base ./essentials.jl:14
  [2] checkbounds
    @ ./abstractarray.jl:699 [inlined]
  [3] getindex
    @ ~/.julia/packages/StrideArraysCore/t77vK/src/ptr_array.jl:1041 [inlined]
  [4] _getindex
    @ ./abstractarray.jl:1336 [inlined]
  [5] getindex
    @ ./abstractarray.jl:1312 [inlined]
  [6] macro expansion
    @ ./REPL[3]:1 [inlined]
  [7] #1
    @ ~/.julia/packages/Polyester/almvr/src/closure.jl:309 [inlined]
  [8] macro expansion
    @ ~/.julia/packages/Polyester/almvr/src/batch.jl:246 [inlined]
  [9] _batch_no_reserve
    @ ~/.julia/packages/Polyester/almvr/src/batch.jl:168 [inlined]
 [10] batch
    @ ~/.julia/packages/Polyester/almvr/src/batch.jl:334 [inlined]
 [11] macro expansion
    @ ~/.julia/packages/Polyester/almvr/src/closure.jl:456 [inlined]
 [12] f!(x::Vector{UInt24}, p::Vector{Int64})
    @ Main ./REPL[3]:1
 [13] top-level scope
    @ REPL[5]:1

My version is:

julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 12 default, 0 interactive, 13 GC (on 12 virtual cores)

(@v1.11) pkg>  st
  [f517fe37] Polyester v0.7.18
  [c3b6d118] BitIntegers v0.3.5

The error does not appear when I use UInt32 instead. I also reported this in BitIntegers here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions