ScottPJones / Mongo.jl

Mongo bindings for the Julia programming language
Other
43 stars 21 forks source link

Accessing invalid BSON field yields inconsistent state #32

Open felipenoris opened 6 years ago

felipenoris commented 6 years ago

In the example below, result is a valid BSONObject instance that doesn't have hey as a key.

Sometimes I also get segfaults.

julia> result["hey"]
ERROR: key not found: "hey"
Stacktrace:
 [1] getindex(::LibBSON.BSONObject, ::String) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONIter.jl:80

julia> result
Error showing value of type LibBSON.BSONObject:
ERROR: ArgumentError: cannot convert NULL to string
Stacktrace:
 [1] unsafe_string at ./strings/string.jl:39 [inlined]
 [2] convert(::Type{AbstractString}, ::LibBSON.BSONObject) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONObject.jl:75
 [3] show(::IOContext{Base.Terminals.TTYTerminal}, ::LibBSON.BSONObject) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONObject.jl:86
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::LibBSON.BSONObject) at ./REPL.jl:122
 [5] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::LibBSON.BSONObject) at ./REPL.jl:125
 [6] display(::LibBSON.BSONObject) at ./multimedia.jl:218
 [7] eval(::Module, ::Any) at ./boot.jl:235
 [8] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [9] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [10] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646