On Mon, May 4, 2015 at 2:15 PM, Narcélio Filho
(I'm resending this because it seems that my other message got garbled.)
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 <cassert> #include <iostream> #include <fstream> #include
#include 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
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'm compiling under Ubuntu 14.10 (amd64):
$ g++ boost-mmap.cpp -lboost_iostreams $ ./a.out 0 2147493647 Segmentation fault (core dumped)
Everything is 64-bits:
You are certain that 'everything' is 64-bits? Without diving too deep into any code, this sounds vaguely, suspiciously like a 32-bit addressing issue. It could even be something as 'simple' as underlying file API, or other, code using shorts, ints, instead of longs, for legacy purposes. Or layers built on said underlying API (i.e. boost wrappers).
$ file a.out a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=d39e3dc0c99e666631747e496bf798b92e4d4c71, not stripped
I have the same issue compiling with Visual Studio and running under Windows 8 (amd64).
What I'm doing wrong?
-- []s, Narcélio.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users