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

Some display methods require the IOStream to be still open #34

Open
giordano opened this issue Oct 30, 2022 · 0 comments
Open

Some display methods require the IOStream to be still open #34

giordano opened this issue Oct 30, 2022 · 0 comments

Comments

@giordano
Copy link
Member

From https://github.com/JuliaBinaryWrappers/RDKit_jll.jl/releases/download/RDKit-v2022.9.1%2B0/RDKit.v2022.9.1.x86_64-w64-mingw32-cxx11.tar.gz

julia> using ObjectFile

julia> readmeta("./librdkitcffi.dll") do oh
           [s for s in Symbols(oh) if contains(symbol_name(s), r"get_(|q)mol")]
       end
3-element Vector{COFFSymbolRef{COFFHandle{IOStream}}}:
Error showing value of type Vector{COFFSymbolRef{COFFHandle{IOStream}}}:
ERROR: SystemError: seek: Bad file descriptor
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:176
  [2] #systemerror#80
    @ ./error.jl:175 [inlined]
  [3] systemerror
    @ ./error.jl:175 [inlined]
  [4] seek(s::IOStream, n::UInt64)
    @ Base ./iostream.jl:129
  [5] seek(oh::COFFHandle{IOStream}, pos::UInt64)
    @ ObjectFile ~/.julia/packages/ObjectFile/lbue6/src/Abstract/ObjectHandle.jl:183
  [6] strtab_lookup(strtab::COFFStrTab{COFFHandle{IOStream}}, index::UInt64)
    @ ObjectFile.COFF ~/.julia/packages/ObjectFile/lbue6/src/COFF/COFFStrTab.jl:18
  [7] symbol_name
    @ ~/.julia/packages/ObjectFile/lbue6/src/COFF/COFFSymbol.jl:125 [inlined]
  [8] show(io::IOContext{IOBuffer}, sym::COFFSymbolRef{COFFHandle{IOStream}})
    @ ObjectFile ~/.julia/packages/ObjectFile/lbue6/src/Abstract/Symbol.jl:233
  [9] sprint(f::Function, args::COFFSymbolRef{COFFHandle{IOStream}}; context::IOContext{Base.TTY}, sizehint::Int64)
    @ Base ./strings/io.jl:112
 [10] alignment(io::IOContext{Base.TTY}, x::COFFSymbolRef{COFFHandle{IOStream}})
    @ Base ./show.jl:2735
 [11] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
    @ Base ./arrayshow.jl:69
 [12] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
    @ Base ./arrayshow.jl:207
 [13] print_matrix(io::IOContext{Base.TTY}, X::Vector{COFFSymbolRef{COFFHandle{IOStream}}}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64) (repeats 2 times)
    @ Base ./arrayshow.jl:171
 [14] print_array
    @ ./arrayshow.jl:358 [inlined]
 [15] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, X::Vector{COFFSymbolRef{COFFHandle{IOStream}}})
    @ Base ./arrayshow.jl:399
 [16] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:267
 [17] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
 [18] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:260
 [19] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:272
 [20] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [21] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
 [22] invokelatest
    @ ./essentials.jl:726 [inlined]
 [23] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:296
 [24] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:278
 [25] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
 [26] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:276
 [27] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:857
 [28] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
 [29] invokelatest
    @ ./essentials.jl:726 [inlined]
 [30] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2510
 [31] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248
 [32] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:484

This makes it hard to use the readmeta method with the function as first argument (which can be used with the do-block syntax), instead

julia> using ObjectFile

julia> io = open("./librdkitcffi.dll", "r")
IOStream(<file ./librdkitcffi.dll>)

julia> oh = readmeta(io)
COFF Handle (64-bit)

julia> [s for s in Symbols(oh) if contains(symbol_name(s), r"get_(|q)mol")]
3-element Vector{COFFSymbolRef{COFFHandle{IOStream}}}:
 COFF Symbol
       Name: get_mol
      Value: 33824
    Defined: Yes
     Strong: Yes
   Locality: Global
 COFF Symbol
       Name: get_qmol
      Value: 35600
    Defined: Yes
     Strong: Yes
   Locality: Global
 COFF Symbol
       Name: get_molblock
      Value: 52240
    Defined: Yes
     Strong: Yes
   Locality: Global

julia> close(io)

works, but it requires more manual steps.

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