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

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

Open
tkf opened this issue May 27, 2020 · 0 comments
Open

Comments

@tkf
Copy link
Collaborator

tkf commented May 27, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant