quinnj / JSON3.jl

Other
214 stars 47 forks source link

JSON3 version 1.14.0 not compiling on julia 1.10 #276

Open simone-silvestri opened 7 months ago

simone-silvestri commented 7 months ago

Hello, I noticed that sometimes, precompiling JSON3 version 1.14.0 with julia 1.10 leads to the following error

ERROR: LoadError: BoundsError: attempt to access 9-element Vector{UInt8} at index [10]
Stacktrace:
  [1] setindex!(A::Vector{UInt8}, x::UInt8, i1::Int64)
    @ Base ./array.jl:1021
  [2] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}; kw::@Kwargs{})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:72
  [3] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:147
  [4] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}; kw::@Kwargs{})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:157
  [5] write
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:147 [inlined]
  [6] write(obj::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}; kw::@Kwargs{})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:40
  [7] write(obj::JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/write.jl:37
  [8] pretty(out::IOBuffer, str::String, ac::JSON3.AlignmentContext; kw::@Kwargs{})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/pretty.jl:84
  [9] pretty
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/pretty.jl:55 [inlined]
 [10] pretty
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/pretty.jl:54 [inlined]
 [11] pretty(out::IOBuffer, x::JSON3.Object{Base.CodeUnits{UInt8, String}, Vector{UInt64}})
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/pretty.jl:54
 [12] macro expansion
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/workload.jl:19 [inlined]
 [13] macro expansion
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/PrecompileTools/kmH5L/src/workloads.jl:78 [inlined]
 [14] top-level scope
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/workload.jl:102
 [15] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [16] include(x::String)
    @ JSON3 /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/JSON3.jl:1
 [17] top-level scope
    @ /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/JSON3.jl:176
 [18] include
    @ ./Base.jl:495 [inlined]
 [19] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base ./loading.jl:2222
 [20] top-level scope
    @ stdin:3
in expression starting at /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/workload.jl:3
in expression starting at /nobackup/users/ssilvest/perlmutter-test/depot/packages/JSON3/jSAdy/src/JSON3.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile JSON3 [0f8b85d8-7281-11e9-16c2-39a750bddbf1] to "/nobackup/users/ssilvest/perlmutter-test/depot/compiled/v1.10/JSON3/jl_qhPnmd".
Stacktrace:

The error disappears if I downgrade to version 1.13.2. I am not sure if this is an error of JSON3 or another package we depend on that uses JSON3. In any case, I thought I would report it.

nuald commented 4 months ago

Seconded. The issue is 100% reproducible with no bound check enabled (I guess that we have an actual issue that is hidden behind the check). STR:

# julia --check-bounds=no
julia> import Pkg; Pkg.add("JSON3")
julia> using JSON3