Can a mapped_file bigger than 2GB be random seeked?

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 | ios::out); assert(mappedFile.is_open()); char buffer[10] = {0}; cout << 0 << endl; file.seekp(0); file.write(buffer, 1); cout << FILESIZE - 1 << endl; file.seekp(FILESIZE - 1); file.write(buffer, 1); cout << 1 * GIGA << endl; file.seekp(1 * GIGA); file.write(buffer, 1); return 0; } I compile and run on Ubuntu 14.10/amd64: $ g++ example.cpp -lboost_iostreams 0 2147493647 Segmentation fault (core dumped) I also get the same error on Windows 8/amd64. What I'm doing wrong? []s, Narcélio.
participants (1)
-
Narcélio Filho