Coder Social home page Coder Social logo

Comments (7)

RazrFalcon avatar RazrFalcon commented on July 29, 2024

I guess you're referring to:

However, some 32-bit and 16-bit platforms may successfully serve a request for more than isize::MAX bytes with things like Physical Address Extension. As such, memory acquired directly from allocators or memory mapped files may be too large to handle with this function.

An assertions would be too sporadic. I guess we should simply return an error and update the docs.

from memmap2-rs.

RazrFalcon avatar RazrFalcon commented on July 29, 2024

I cannot find how std::fs::read handles this. It should have the exact issue.

from memmap2-rs.

RazrFalcon avatar RazrFalcon commented on July 29, 2024

@adamreichold Hi! Can you comment on this one? It fills like half of the bugs we had are 32-bit related. But disabling its support completely would be too much.

from memmap2-rs.

LegionMammal978 avatar LegionMammal978 commented on July 29, 2024

I cannot find how std::fs::read handles this. It should have the exact issue.

Following the call chain, std::fs::read()

  1. calls <File as Read>::read_to_end(),
  2. which calls Vec::<u8>::reserve(),
  3. which calls RawVec::<u8>::reserve(),
  4. which calls RawVec::reserve::do_reserve_and_handle::<u8, Global>(),
  5. which calls RawVec::<u8>::grow_amortized(),
  6. which calls alloc::raw_vec::finish_grow::<Global>(),
  7. which calls alloc::raw_vec::alloc_guard(),
  8. which checks the size in bytes against isize::MAX as usize.

Even if it fails to get the file size, it

  1. calls std::io::default_read_to_end(),
  2. which repeatedly calls Vec::<u8>::extend_from_slice(),
  3. which calls <Vec<u8> as SpecExtend<&u8, slice::Iter<'_, u8>>::spec_extend(),
  4. which calls Vec::<u8>::append_elements(),
  5. which calls Vec::<u8>::reserve(),
  6. which checks the size as before.

from memmap2-rs.

RazrFalcon avatar RazrFalcon commented on July 29, 2024

Nice find! I guess I will borrow this function.

from memmap2-rs.

adamreichold avatar adamreichold commented on July 29, 2024

@adamreichold Hi! Can you comment on this one? It fills like half of the bugs we had are 32-bit related. But disabling its support completely would be too much.

I think it is a straight-forward error on our side. We do have the necessary check for file-based mappings in MmapOptions::get_len, but not in MmapOptions::len.

from memmap2-rs.

adamreichold avatar adamreichold commented on July 29, 2024

I think our check in get_len was actually too lenient as well. I still think this is a straight-forward bug though, as exposing mmap (2), we are in the memory allocator business need to take the same care as other implementors of such functionality. 😓

from memmap2-rs.

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.