Skip to content

Trying to a pretty-print object that calls logger via show crashes Julia #30

Open
@tkf

Description

@tkf

MWE

struct MyIterator end
function Base.iterate(itr::MyIterator)
    # @info "itearte(itr::MyIterator)" itr
    return (:first, nothing)
end
Base.iterate(::MyIterator, ::Nothing) = nothing

function Base.show(io::IO, ::MIME"text/plain", itr::MyIterator)
    print(io, "MyIterator: ")
    join(io, itr, ", ")
end

Commenting out the line with @info and invoking show on MyIterator causes a segfault.

Since it's so easy to put @info and @debug for method that might be called from show, I think it'd be nice to detect infinite recursion. It might be a nice use-case of the context variables JuliaLang/julia#35833 (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