Boost logo

Boost Users :

Subject: [Boost-users] Can a mapped_file bigger than 2GB be random seeked?
From: Narcélio Filho (narcelio_at_[hidden])
Date: 2015-05-04 02:11:16


Hello!

I'm writting on random positions on a mapped file, but it seems that if I
seek past 2GB, write something, then seek to a lower position, I got a
segfault. Here is the code:

#include <iostream>
#include <fstream>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/mapped_file.hpp>

using namespace std;
using boost::iostreams::stream;
using boost::iostreams::mapped_file;

int main(int argc, char** argv)
{
    const size_t GIGA = 1024l*1024l*1024l;
    const size_t FILESIZE = 2l * GIGA + 10000;

    ofstream block("file", ios::binary | ios::out);
    assert(block.good());

    block.seekp(FILESIZE);
    block.write("", 1);
    block.close();

    mapped_file mappedFile("file");
    stream<mapped_file> file(mappedFile, ios::binary¥½Ìèé½ÕФì((€€€…ÍÍ•ÉСµ…ÁÁ•‘¥±”¹¥Í}½Á•¸ ¤¤ì((€€€¡…ȁ‰Õ™™•ÉlÄÁt€ôìÁôì((€€€½ÕЀðð€À€ðð•¹‘°ì(€€€™¥±”¹Í••­À À¤ì(€€€™¥±”¹Ýɥє¡‰Õ™™•È°€Ä¤ì((€€€½ÕЀðð%1M%i€´€Ä€ðð•¹‘°ì(€€€™¥±”¹Í••­À¡%1M%i€´€Ä¤ì(€€€™¥±”¹Ýɥє¡‰Õ™™•È°€Ä¤ì((€€€½ÕЀðð€Ä€¨%€ðð•¹‘°ì(€€€™¥±”¹Í••­À Ä€¨%¤ì(€€€™¥±”¹Ýɥє¡‰Õ™™•È°€Ä¤ì((€€€É•ÑÕɸ€Àì)ô(()$½µÁ¥±”…¹ÉÕ¸½¸U‰Õ¹ÑÔ€ÄиÄÀ½…µØÐè((œ¬¬•á…µÁ±”¹ÁÀ€µ±‰½½ÍÑ}¥½ÍÑÉ•…µÌ(À(ÈÄÐÜÐäÌØÐÜ)M•µ•¹Ñ…Ñ¥½¸™…ձЀ¡½É”‘ÕµÁ•¤(()$…±Í¼•ÐÑ¡”Í…µ”•Éɽȁ½¸]¥¹‘½Ý̀ཅµØи(()]¡…Ё$´‘½¥¹œÝɽ¹œü(()muÌ°9…ɏ¥±¥¼¸(


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net