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

Julia nightly: ERROR: TypeError: in RefArray, in A, expected A<:(AbstractArray{Ptr{UInt8}}), got Type{Vector{Ptr{Gray{N0f8}}}} #74

Closed
IanButterworth opened this issue Nov 28, 2023 · 3 comments · Fixed by #73
Labels
bug Something isn't working

Comments

@IanButterworth
Copy link
Member

IanButterworth commented Nov 28, 2023

julia> using PNGFiles

julia> PNGFiles.load(pkgdir(PNGFiles, "test/temp/PngSuite/basi0g01.png"))
ERROR: TypeError: in RefArray, in A, expected A<:(AbstractArray{Ptr{UInt8}}), got Type{Vector{Ptr{Gray{N0f8}}}}
Stacktrace:
  [1] Ref{Ptr{UInt8}}(a::Vector{Ptr{Gray{N0f8}}})
    @ Base ./refpointer.jl:158
  [2] cconvert(::Type{Ptr{Ptr{UInt8}}}, a::Vector{Ptr{Gray{N0f8}}})
    @ Base ./refpointer.jl:176
  [3] png_read_image(png_ptr::Ptr{Nothing}, image::Vector{Ptr{Gray{N0f8}}})
    @ PNGFiles ~/.julia/dev/PNGFiles/gen/libpng/libpng_api.jl:558
  [4] _load!(buffer::Matrix{Gray{N0f8}}, png_ptr::Ptr{Nothing}, info_ptr::Ptr{Nothing})
    @ PNGFiles ~/.julia/dev/PNGFiles/src/io.jl:256
  [5] #invokelatest#2
    @ Base ./essentials.jl:955 [inlined]
  [6] invokelatest
    @ Base ./essentials.jl:952 [inlined]
  [7] _load(png_ptr::Ptr{Nothing}, info_ptr::Ptr{Nothing}; gamma::Nothing, expand_paletted::Bool, background::Bool)
    @ PNGFiles ~/.julia/dev/PNGFiles/src/io.jl:243
  [8] _load
    @ PNGFiles ~/.julia/dev/PNGFiles/src/io.jl:105 [inlined]
  [9] load(fpath::String; gamma::Nothing, expand_paletted::Bool, background::Bool)
    @ PNGFiles ~/.julia/dev/PNGFiles/src/io.jl:54
 [10] load(fpath::String)
    @ PNGFiles ~/.julia/dev/PNGFiles/src/io.jl:47
 [11] top-level scope
    @ REPL[8]:1

function png_read_image(png_ptr, image)
ccall((:png_read_image, libpng), Cvoid, (png_structrp, png_bytepp), png_ptr, image)
end

PNGFiles.jl/src/io.jl

Lines 255 to 260 in f1bf24f

function _load!(buffer::Matrix{T}, png_ptr, info_ptr) where T # separate to support precompilation of permutedims
png_read_image(png_ptr, map(pointer, eachcol(buffer)))
png_read_end(png_ptr, info_ptr)
png_destroy_read_struct(Ref{Ptr{Cvoid}}(png_ptr), Ref{Ptr{Cvoid}}(info_ptr), C_NULL)
return permutedims(buffer, (2, 1))
end

@IanButterworth IanButterworth added the bug Something isn't working label Nov 28, 2023
@jmert
Copy link

jmert commented Nov 28, 2023

I was already in the process of digging into this because GLMakie failing to precompile/load on master was annoying me, so I ran a bisection earlier today and isolated the change to JuliaLang/julia#51764.

In my few minutes of trials, it seems to work if line 256 in the _load! function is changed to map(pointer, eachcol(reinterpret(UInt8, buffer))), but I haven't done any extensive validation yet.

@IanButterworth
Copy link
Member Author

Thanks. That does make tests pass. Though I want to make sure it's not causing undetected corruption #73

@IanButterworth
Copy link
Member Author

Fix released in 0.4.2 JuliaRegistries/General#96151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants