Code Monkey home page Code Monkey logo

Comments (17)

saghm avatar saghm commented on September 27, 2024 2

@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.

kyeah avatar kyeah commented on September 27, 2024 1

Great investigations, thanks @zonyitoo + @neosilky!

from bson-rust.

zonyitoo avatar zonyitoo commented on September 27, 2024

cc @kyeah

from bson-rust.

kyeah avatar kyeah commented on September 27, 2024

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.

daniellockyer avatar daniellockyer commented on September 27, 2024

Hey @kyeah & @zonyitoo,

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.

zonyitoo avatar zonyitoo commented on September 27, 2024

@neosilky Is this what you are expecting? :)

from bson-rust.

daniellockyer avatar daniellockyer commented on September 27, 2024

@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.

zonyitoo avatar zonyitoo commented on September 27, 2024
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.

zonyitoo avatar zonyitoo commented on September 27, 2024

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.

zonyitoo avatar zonyitoo commented on September 27, 2024

It won't panic now. But return a DecoderError.

from bson-rust.

daniellockyer avatar daniellockyer commented on September 27, 2024

@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.

zonyitoo avatar zonyitoo commented on September 27, 2024

Ahh.. the nsecs overflows u32 ...

from bson-rust.

zonyitoo avatar zonyitoo commented on September 27, 2024

@neosilky This commit should fix the issue.

from bson-rust.

zonyitoo avatar zonyitoo commented on September 27, 2024

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.

zonyitoo avatar zonyitoo commented on September 27, 2024

Ah my fault.... the time variable is a i64, which means that it may be < 0.

from bson-rust.

zonyitoo avatar zonyitoo commented on September 27, 2024

Fixed. And close.
cc @killercup . Sorry for fixing this issue after over half a year.

from bson-rust.

daniellockyer avatar daniellockyer commented on September 27, 2024

Thanks!

from bson-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.