Comments (17)
@zonyitoo note that mgo is neither an official MongoDB driver nor actively maintained; the official (albeit pre-stable) Go driver is here
from bson-rust.
Great investigations, thanks @zonyitoo + @neosilky!
from bson-rust.
cc @kyeah
from bson-rust.
nice, thanks 🙇
Gonna use this as a tracking issue instead of splitting it out since this seems like a nice concise set.
- "thread panicked at 'No such local time'"
From: chrono-0.2.25/src/offset/mod.rs:151 via src/decoder/mod.rs:172 - "thread '' panicked at 'attempt to multiply with overflow'" - src/decoder/mod.rs:172
- "thread '' panicked at 'attempt to subtract with overflow'" src/decoder/mod.rs:45
- "AddressSanitizer failed to allocate 0xffffffff93000000 bytes"
from bson-rust.
It looks like chrono comes with a timestamp_opt method that would allow you to capture the error instead of allowing chrono to panic.
from bson-rust.
@neosilky Is this what you are expecting? :)
from bson-rust.
@zonyitoo Yes - nice job!
So I'm still hitting the attempt to subtract with overflow
panic in src/decoder/mod:50
and I'm getting two fatal runtime error: memory allocation failed
errors, which are weird.
from bson-rust.
attempt to subtract with overflow
That's weird... src/decoder/mod:50
is read_string
, which is a UTF-8 string in BSON. In BSON's spec, UTF-8 String must be ended with \x00
, which means that the length of string must be >= 1
.
string ::= int32 (byte*) "\x00" String - The int32 is the number bytes in the (byte*) + 1 (for the trailing '\x00'). The (byte*) is zero or more UTF-8 encoded characters.
What should I do for length = 0? ... Hmmm....
Can you dump the original binary data?
from bson-rust.
It seems that the Go's implementation will also crash in this case: https://github.com/go-mgo/mgo/blob/v2/bson/decode.go#L771-L772 .
The official Python BSON implementation will raise an exception: https://github.com/mongodb/mongo-python-driver/blob/master/bson/__init__.py#L175-L178 .
from bson-rust.
It won't panic now. But return a DecoderError.
from bson-rust.
@zonyitoo Nice one, it looks like you've done a sane thing 😀
I'm now getting one weird memory issue and a 'attempt to multiply with overflow'
in src/decoder/mod.rs:208
AKA https://github.com/zonyitoo/bson-rs/blob/master/src/decoder/mod.rs#L208
from bson-rust.
Ahh.. the nsecs
overflows u32
...
from bson-rust.
@neosilky This commit should fix the issue.
from bson-rust.
Wait a minute... ((time % 1000) as u32) * 1_000_000
won't overflow u32
...
999 * 1_000_000 < u32::max_value() aka 4294967296
@neosilky Can you give me a BSON encoded buffer, which can reproduce attempt to multiply with overflow
?
from bson-rust.
Ah my fault.... the time
variable is a i64
, which means that it may be < 0
.
from bson-rust.
Fixed. And close.
cc @killercup . Sorry for fixing this issue after over half a year.
from bson-rust.
Thanks!
from bson-rust.
Related Issues (20)
- serde_with `SerializeAs` & `DeserializeAs` support for time crate HOT 2
- Add Option<ObjectId> serialize_object_id_as_hex_string support HOT 3
- Serialising and deserialising a BSON document with Regex can change the document HOT 3
- Better Details for BSON Deserialization Errors HOT 5
- use simd to optimize uft8 validation. HOT 3
- Bson fails to serialize AND deserialize IPAddr keys in hashmaps HOT 3
- `js-sys` should not be used when targeting `wasm32-wasi` HOT 3
- add ObjectId deserialization from sequence to support messagepack HOT 8
- Inconsistency between documentation and code implementation HOT 3
- RUST-1892 incorrect serialization/deserializer on big endian machines ( s390x ) HOT 5
- Serialization issue with Uuid HOT 3
- RUST-1899 Deserialization with UUID HOT 5
- How to deserialize ISO formatted json into Bson::DateTime HOT 1
- Time's "large-dates" feature should be optional HOT 1
- document has bytes remaining that were not visited HOT 7
- Operating on BSON Decimal128 type HOT 2
- Add chrono::TimeDelta to mongodb::bson::DateTime HOT 2
- [feat] Ordering feature for bson serialization HOT 2
- RUST-2019 Formatter for `Bson` ignores pretty printing `{:#}` HOT 1
- Impl Hash/Eq on BSON
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bson-rust.