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

Support for #undef #19

Closed
Liozou opened this issue Aug 21, 2024 · 2 comments
Closed

Support for #undef #19

Liozou opened this issue Aug 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Liozou
Copy link

Liozou commented Aug 21, 2024

Hey there, thanks for this excellent package!
Do you plan on supporting uninitialized structs ? I'm thinking specifically of the non-isbits ones, which can contain #undef values such as :

julia> about(Ref{String}())
Base.RefValue{String} (mutable) (<: Ref{String} <: Any), occupies 8B.
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] memorylayout(io::Base.TTY, value::Base.RefValue{String})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:78
 [2] about(io::Base.TTY, value::Base.RefValue{String})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:43
 [3] about(x::Base.RefValue{String})
   @ About ~/.julia/packages/About/52iMk/src/About.jl:201
 [4] top-level scope
   @ REPL[12]:1

Similarly, for Memory :

julia> about(Memory{Any}(undef, 3))
3-element Memory{Any} (mutable) (<: DenseVector{Any} <: AbstractVector{Any} <: Any)
 Memory footprint: 24B directly (referencing 40B in total)
ERROR: Abstract type Any does not have a definite size.
Stacktrace:
 [1] sizeof(x::Type)
   @ Base ./essentials.jl:768
 [2] memorylayout(io::Base.TTY, mem::Memory{Any})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:385
 [3] about(io::Base.TTY, value::Memory{Any})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:43
 [4] about(x::Memory{Any})
   @ About ~/.julia/packages/About/52iMk/src/About.jl:201
 [5] top-level scope
   @ REPL[10]:1
@tecosaur
Copy link
Owner

This isn't something I've tested, but it would be good to make it not error if nothing else :)

@tecosaur tecosaur added the bug Something isn't working label Oct 18, 2024
@tecosaur
Copy link
Owner

This should be fixed as of b4ae600 🙂

julia> about(Ref{String}())
Base.RefValue{String} (mutable) (<: Ref{String} <: Any), occupies 8B.
 x::String 8B #undef Uninitialised value

 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                                   *                                   

 * = Pointer (8B)

julia> about(Memory{Any}(undef, 3))
3-element Memory{Any} (mutable) (<: DenseVector{Any} <: AbstractVector{Any} <: Any), occupies 24B directly (referencing 40B in total)

 Memory block (CPU-addressed) from 0x00007f2b25b97dd0 to 0x00007f2b25b97de8.

 ┌───────────────────────────╴#undef╶───────────────────────────┐ ⋯(×1)⋯ ┌───────────────────────────╴#undef╶───────────────────────────┐  3 items
 0000000000000000000000000000000000000000000000000000000000000000        0000000000000000000000000000000000000000000000000000000000000000    in
 └─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘ ⋯(×8)⋯ └─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘└─0x00─┘ 24 bytes

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

No branches or pull requests

2 participants