Cannot read from Boost::mapped_file: Data buffer is NULL
up vote
0
down vote
favorite
I'm trying to read from a mapped file in chunks (hence the buffer_size and file_offset arguments) but the buffer is always NULL. The file is opened successfully. My code is the following:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
using std::ios;
using std::ifstream;
char *read_mapped_bytes(const char *file_path, boost::iostreams::mapped_file mapped_file,
unsigned long long int buffer_size, unsigned long long int file_offset) {
const filesystem::path memory_dump_file{file_path};
mapped_file.open(memory_dump_file, boost::iostreams::mapped_file::readonly, buffer_size,
static_cast<boost::iostreams::stream_offset>(file_offset));
if (mapped_file.is_open()) {
auto read_buffer = mapped_file.data();
if (read_buffer == nullptr) {
printf("The mapped file buffer was NULL");
exit(-1);
}
return read_buffer;
} else {
printf("Failed to open mapped file");
exit(-1);
}
}
int main(int argc, char *argv) {
boost::iostreams::mapped_file mapped_file;
auto buffer = read_mapped_bytes((const char *) "/mnt/d/Cpp/MyProject/myFile.bin", mapped_file,
(unsigned long long int) 1000, (unsigned long long int) 0);
exit(EXIT_SUCCESS);
}
Note that the file path is correct since otherwise it would cause an exception:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::ios_base::failure[abi:cxx11]> >'
what(): failed opening file: No such file or directory: iostream error
The code has been ran on Ubuntu 18.04.01 LTS using WSL (Windows Subsystem for Linux).
The strace (strace -ff -o test.txt ./BoostTesting) of the code execution is the following:
execve("./BoostTesting", ["./BoostTesting"], 0x7fffc2c75168 /* 17 vars */) = 0
brk(NULL) = 0x7fffc5980000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48784, ...}) = 0
mmap(NULL, 48784, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4759dab000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1200300"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=105032, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759da0000
mmap(NULL, 2200080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47597e0000
mprotect(0x7f47597f8000, 2097152, PROT_NONE) = 0
mmap(0x7f47599f8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18000) = 0x7f47599f8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>100030"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=18544, ...}) = 0
mmap(NULL, 2113856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47595d0000
mprotect(0x7f47595d4000, 2093056, PROT_NONE) = 0
mmap(0x7f47597d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f47597d3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>136030310"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1594832, ...}) = 0
mmap(NULL, 3702816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759240000
mprotect(0x7f47593b9000, 2097152, PROT_NONE) = 0
mmap(0x7f47595b9000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f47595b9000
mmap(0x7f47595c5000, 12320, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47595c5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1300*"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759020000
mprotect(0x7f4759037000, 2093056, PROT_NONE) = 0
mmap(0x7f4759236000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f4759236000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1260342"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758c20000
mprotect(0x7f4758e07000, 2097152, PROT_NONE) = 0
mmap(0x7f4759007000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f4759007000
mmap(0x7f475900d000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f475900d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>122037"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=116960, ...}) = 0
mmap(NULL, 2212016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758a00000
mprotect(0x7f4758a1c000, 2093056, PROT_NONE) = 0
mmap(0x7f4758c1b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0x7f4758c1b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1`23"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=66800, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d90000
mmap(NULL, 2161864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47587f0000
mprotect(0x7f47587ff000, 2093056, PROT_NONE) = 0
mmap(0x7f47589fe000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f47589fe000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1000b"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47585d0000
mprotect(0x7f47585ea000, 2093056, PROT_NONE) = 0
mmap(0x7f47587e9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f47587e9000
mmap(0x7f47587eb000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47587eb000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1200272"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758230000
mprotect(0x7f47583cd000, 2093056, PROT_NONE) = 0
mmap(0x7f47585cc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7f47585cc000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d80000
arch_prctl(ARCH_SET_FS, 0x7f4759d811c0) = 0
mprotect(0x7f4759007000, 16384, PROT_READ) = 0
mprotect(0x7f47585cc000, 4096, PROT_READ) = 0
mprotect(0x7f47587e9000, 4096, PROT_READ) = 0
mprotect(0x7f47589fe000, 4096, PROT_READ) = 0
mprotect(0x7f4758c1b000, 4096, PROT_READ) = 0
mprotect(0x7f4759236000, 4096, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d70000
mprotect(0x7f47595b9000, 40960, PROT_READ) = 0
mprotect(0x7f47597d3000, 4096, PROT_READ) = 0
mprotect(0x7f47599f8000, 4096, PROT_READ) = 0
mprotect(0x7f475a008000, 4096, PROT_READ) = 0
mprotect(0x7f4759c27000, 4096, PROT_READ) = 0
munmap(0x7f4759dab000, 48784) = 0
set_tid_address(0x7f4759d81490) = 1491
set_robust_list(0x7f4759d814a0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f47585d5cb0, sa_mask=, sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f47585d5d50, sa_mask=, sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=8192*1024}) = 0
brk(NULL) = 0x7fffc5980000
brk(0x7fffc59a1000) = 0x7fffc59a1000
futex(0x7f47595c607c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f47595c6088, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/mnt/d/Cpp/MyProject/myFile.bin", O_RDONLY) = 3
mmap(NULL, 1000, PROT_READ, MAP_SHARED, 3, 0) = 0x7f4759db6000
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 1), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "The mapped file buffer was NULL", 31) = 31
exit_group(-1) = ?
+++ exited with 255 +++
Note that when compiling for Windows the same problem arises so it's most likely a bug in my code or Boost.
c++ boost windows-subsystem-for-linux memory-mapped-files
add a comment |
up vote
0
down vote
favorite
I'm trying to read from a mapped file in chunks (hence the buffer_size and file_offset arguments) but the buffer is always NULL. The file is opened successfully. My code is the following:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
using std::ios;
using std::ifstream;
char *read_mapped_bytes(const char *file_path, boost::iostreams::mapped_file mapped_file,
unsigned long long int buffer_size, unsigned long long int file_offset) {
const filesystem::path memory_dump_file{file_path};
mapped_file.open(memory_dump_file, boost::iostreams::mapped_file::readonly, buffer_size,
static_cast<boost::iostreams::stream_offset>(file_offset));
if (mapped_file.is_open()) {
auto read_buffer = mapped_file.data();
if (read_buffer == nullptr) {
printf("The mapped file buffer was NULL");
exit(-1);
}
return read_buffer;
} else {
printf("Failed to open mapped file");
exit(-1);
}
}
int main(int argc, char *argv) {
boost::iostreams::mapped_file mapped_file;
auto buffer = read_mapped_bytes((const char *) "/mnt/d/Cpp/MyProject/myFile.bin", mapped_file,
(unsigned long long int) 1000, (unsigned long long int) 0);
exit(EXIT_SUCCESS);
}
Note that the file path is correct since otherwise it would cause an exception:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::ios_base::failure[abi:cxx11]> >'
what(): failed opening file: No such file or directory: iostream error
The code has been ran on Ubuntu 18.04.01 LTS using WSL (Windows Subsystem for Linux).
The strace (strace -ff -o test.txt ./BoostTesting) of the code execution is the following:
execve("./BoostTesting", ["./BoostTesting"], 0x7fffc2c75168 /* 17 vars */) = 0
brk(NULL) = 0x7fffc5980000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48784, ...}) = 0
mmap(NULL, 48784, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4759dab000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1200300"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=105032, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759da0000
mmap(NULL, 2200080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47597e0000
mprotect(0x7f47597f8000, 2097152, PROT_NONE) = 0
mmap(0x7f47599f8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18000) = 0x7f47599f8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>100030"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=18544, ...}) = 0
mmap(NULL, 2113856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47595d0000
mprotect(0x7f47595d4000, 2093056, PROT_NONE) = 0
mmap(0x7f47597d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f47597d3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>136030310"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1594832, ...}) = 0
mmap(NULL, 3702816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759240000
mprotect(0x7f47593b9000, 2097152, PROT_NONE) = 0
mmap(0x7f47595b9000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f47595b9000
mmap(0x7f47595c5000, 12320, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47595c5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1300*"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759020000
mprotect(0x7f4759037000, 2093056, PROT_NONE) = 0
mmap(0x7f4759236000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f4759236000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1260342"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758c20000
mprotect(0x7f4758e07000, 2097152, PROT_NONE) = 0
mmap(0x7f4759007000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f4759007000
mmap(0x7f475900d000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f475900d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>122037"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=116960, ...}) = 0
mmap(NULL, 2212016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758a00000
mprotect(0x7f4758a1c000, 2093056, PROT_NONE) = 0
mmap(0x7f4758c1b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0x7f4758c1b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1`23"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=66800, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d90000
mmap(NULL, 2161864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47587f0000
mprotect(0x7f47587ff000, 2093056, PROT_NONE) = 0
mmap(0x7f47589fe000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f47589fe000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1000b"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47585d0000
mprotect(0x7f47585ea000, 2093056, PROT_NONE) = 0
mmap(0x7f47587e9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f47587e9000
mmap(0x7f47587eb000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47587eb000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1200272"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758230000
mprotect(0x7f47583cd000, 2093056, PROT_NONE) = 0
mmap(0x7f47585cc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7f47585cc000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d80000
arch_prctl(ARCH_SET_FS, 0x7f4759d811c0) = 0
mprotect(0x7f4759007000, 16384, PROT_READ) = 0
mprotect(0x7f47585cc000, 4096, PROT_READ) = 0
mprotect(0x7f47587e9000, 4096, PROT_READ) = 0
mprotect(0x7f47589fe000, 4096, PROT_READ) = 0
mprotect(0x7f4758c1b000, 4096, PROT_READ) = 0
mprotect(0x7f4759236000, 4096, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d70000
mprotect(0x7f47595b9000, 40960, PROT_READ) = 0
mprotect(0x7f47597d3000, 4096, PROT_READ) = 0
mprotect(0x7f47599f8000, 4096, PROT_READ) = 0
mprotect(0x7f475a008000, 4096, PROT_READ) = 0
mprotect(0x7f4759c27000, 4096, PROT_READ) = 0
munmap(0x7f4759dab000, 48784) = 0
set_tid_address(0x7f4759d81490) = 1491
set_robust_list(0x7f4759d814a0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f47585d5cb0, sa_mask=, sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f47585d5d50, sa_mask=, sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=8192*1024}) = 0
brk(NULL) = 0x7fffc5980000
brk(0x7fffc59a1000) = 0x7fffc59a1000
futex(0x7f47595c607c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f47595c6088, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/mnt/d/Cpp/MyProject/myFile.bin", O_RDONLY) = 3
mmap(NULL, 1000, PROT_READ, MAP_SHARED, 3, 0) = 0x7f4759db6000
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 1), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "The mapped file buffer was NULL", 31) = 31
exit_group(-1) = ?
+++ exited with 255 +++
Note that when compiling for Windows the same problem arises so it's most likely a bug in my code or Boost.
c++ boost windows-subsystem-for-linux memory-mapped-files
Can you provide thestracelog file from WSL? Commandstrace -ff -o test.txt your_command.
– Biswapriyo
Nov 22 at 19:31
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
Short compilable example and fullstraceadded now
– BullyWiiPlaza
Nov 23 at 12:39
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to read from a mapped file in chunks (hence the buffer_size and file_offset arguments) but the buffer is always NULL. The file is opened successfully. My code is the following:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
using std::ios;
using std::ifstream;
char *read_mapped_bytes(const char *file_path, boost::iostreams::mapped_file mapped_file,
unsigned long long int buffer_size, unsigned long long int file_offset) {
const filesystem::path memory_dump_file{file_path};
mapped_file.open(memory_dump_file, boost::iostreams::mapped_file::readonly, buffer_size,
static_cast<boost::iostreams::stream_offset>(file_offset));
if (mapped_file.is_open()) {
auto read_buffer = mapped_file.data();
if (read_buffer == nullptr) {
printf("The mapped file buffer was NULL");
exit(-1);
}
return read_buffer;
} else {
printf("Failed to open mapped file");
exit(-1);
}
}
int main(int argc, char *argv) {
boost::iostreams::mapped_file mapped_file;
auto buffer = read_mapped_bytes((const char *) "/mnt/d/Cpp/MyProject/myFile.bin", mapped_file,
(unsigned long long int) 1000, (unsigned long long int) 0);
exit(EXIT_SUCCESS);
}
Note that the file path is correct since otherwise it would cause an exception:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::ios_base::failure[abi:cxx11]> >'
what(): failed opening file: No such file or directory: iostream error
The code has been ran on Ubuntu 18.04.01 LTS using WSL (Windows Subsystem for Linux).
The strace (strace -ff -o test.txt ./BoostTesting) of the code execution is the following:
execve("./BoostTesting", ["./BoostTesting"], 0x7fffc2c75168 /* 17 vars */) = 0
brk(NULL) = 0x7fffc5980000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48784, ...}) = 0
mmap(NULL, 48784, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4759dab000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1200300"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=105032, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759da0000
mmap(NULL, 2200080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47597e0000
mprotect(0x7f47597f8000, 2097152, PROT_NONE) = 0
mmap(0x7f47599f8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18000) = 0x7f47599f8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>100030"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=18544, ...}) = 0
mmap(NULL, 2113856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47595d0000
mprotect(0x7f47595d4000, 2093056, PROT_NONE) = 0
mmap(0x7f47597d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f47597d3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>136030310"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1594832, ...}) = 0
mmap(NULL, 3702816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759240000
mprotect(0x7f47593b9000, 2097152, PROT_NONE) = 0
mmap(0x7f47595b9000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f47595b9000
mmap(0x7f47595c5000, 12320, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47595c5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1300*"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759020000
mprotect(0x7f4759037000, 2093056, PROT_NONE) = 0
mmap(0x7f4759236000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f4759236000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1260342"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758c20000
mprotect(0x7f4758e07000, 2097152, PROT_NONE) = 0
mmap(0x7f4759007000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f4759007000
mmap(0x7f475900d000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f475900d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>122037"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=116960, ...}) = 0
mmap(NULL, 2212016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758a00000
mprotect(0x7f4758a1c000, 2093056, PROT_NONE) = 0
mmap(0x7f4758c1b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0x7f4758c1b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1`23"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=66800, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d90000
mmap(NULL, 2161864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47587f0000
mprotect(0x7f47587ff000, 2093056, PROT_NONE) = 0
mmap(0x7f47589fe000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f47589fe000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1000b"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47585d0000
mprotect(0x7f47585ea000, 2093056, PROT_NONE) = 0
mmap(0x7f47587e9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f47587e9000
mmap(0x7f47587eb000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47587eb000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1200272"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758230000
mprotect(0x7f47583cd000, 2093056, PROT_NONE) = 0
mmap(0x7f47585cc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7f47585cc000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d80000
arch_prctl(ARCH_SET_FS, 0x7f4759d811c0) = 0
mprotect(0x7f4759007000, 16384, PROT_READ) = 0
mprotect(0x7f47585cc000, 4096, PROT_READ) = 0
mprotect(0x7f47587e9000, 4096, PROT_READ) = 0
mprotect(0x7f47589fe000, 4096, PROT_READ) = 0
mprotect(0x7f4758c1b000, 4096, PROT_READ) = 0
mprotect(0x7f4759236000, 4096, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d70000
mprotect(0x7f47595b9000, 40960, PROT_READ) = 0
mprotect(0x7f47597d3000, 4096, PROT_READ) = 0
mprotect(0x7f47599f8000, 4096, PROT_READ) = 0
mprotect(0x7f475a008000, 4096, PROT_READ) = 0
mprotect(0x7f4759c27000, 4096, PROT_READ) = 0
munmap(0x7f4759dab000, 48784) = 0
set_tid_address(0x7f4759d81490) = 1491
set_robust_list(0x7f4759d814a0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f47585d5cb0, sa_mask=, sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f47585d5d50, sa_mask=, sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=8192*1024}) = 0
brk(NULL) = 0x7fffc5980000
brk(0x7fffc59a1000) = 0x7fffc59a1000
futex(0x7f47595c607c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f47595c6088, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/mnt/d/Cpp/MyProject/myFile.bin", O_RDONLY) = 3
mmap(NULL, 1000, PROT_READ, MAP_SHARED, 3, 0) = 0x7f4759db6000
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 1), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "The mapped file buffer was NULL", 31) = 31
exit_group(-1) = ?
+++ exited with 255 +++
Note that when compiling for Windows the same problem arises so it's most likely a bug in my code or Boost.
c++ boost windows-subsystem-for-linux memory-mapped-files
I'm trying to read from a mapped file in chunks (hence the buffer_size and file_offset arguments) but the buffer is always NULL. The file is opened successfully. My code is the following:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
using std::ios;
using std::ifstream;
char *read_mapped_bytes(const char *file_path, boost::iostreams::mapped_file mapped_file,
unsigned long long int buffer_size, unsigned long long int file_offset) {
const filesystem::path memory_dump_file{file_path};
mapped_file.open(memory_dump_file, boost::iostreams::mapped_file::readonly, buffer_size,
static_cast<boost::iostreams::stream_offset>(file_offset));
if (mapped_file.is_open()) {
auto read_buffer = mapped_file.data();
if (read_buffer == nullptr) {
printf("The mapped file buffer was NULL");
exit(-1);
}
return read_buffer;
} else {
printf("Failed to open mapped file");
exit(-1);
}
}
int main(int argc, char *argv) {
boost::iostreams::mapped_file mapped_file;
auto buffer = read_mapped_bytes((const char *) "/mnt/d/Cpp/MyProject/myFile.bin", mapped_file,
(unsigned long long int) 1000, (unsigned long long int) 0);
exit(EXIT_SUCCESS);
}
Note that the file path is correct since otherwise it would cause an exception:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::ios_base::failure[abi:cxx11]> >'
what(): failed opening file: No such file or directory: iostream error
The code has been ran on Ubuntu 18.04.01 LTS using WSL (Windows Subsystem for Linux).
The strace (strace -ff -o test.txt ./BoostTesting) of the code execution is the following:
execve("./BoostTesting", ["./BoostTesting"], 0x7fffc2c75168 /* 17 vars */) = 0
brk(NULL) = 0x7fffc5980000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48784, ...}) = 0
mmap(NULL, 48784, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4759dab000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1200300"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=105032, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759da0000
mmap(NULL, 2200080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47597e0000
mprotect(0x7f47597f8000, 2097152, PROT_NONE) = 0
mmap(0x7f47599f8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18000) = 0x7f47599f8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>100030"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=18544, ...}) = 0
mmap(NULL, 2113856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47595d0000
mprotect(0x7f47595d4000, 2093056, PROT_NONE) = 0
mmap(0x7f47597d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f47597d3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>136030310"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1594832, ...}) = 0
mmap(NULL, 3702816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759240000
mprotect(0x7f47593b9000, 2097152, PROT_NONE) = 0
mmap(0x7f47595b9000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f47595b9000
mmap(0x7f47595c5000, 12320, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47595c5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1300*"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4759020000
mprotect(0x7f4759037000, 2093056, PROT_NONE) = 0
mmap(0x7f4759236000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f4759236000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1260342"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758c20000
mprotect(0x7f4758e07000, 2097152, PROT_NONE) = 0
mmap(0x7f4759007000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f4759007000
mmap(0x7f475900d000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f475900d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>122037"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=116960, ...}) = 0
mmap(NULL, 2212016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758a00000
mprotect(0x7f4758a1c000, 2093056, PROT_NONE) = 0
mmap(0x7f4758c1b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0x7f4758c1b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1`23"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=66800, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d90000
mmap(NULL, 2161864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47587f0000
mprotect(0x7f47587ff000, 2093056, PROT_NONE) = 0
mmap(0x7f47589fe000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f47589fe000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1000b"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f47585d0000
mprotect(0x7f47585ea000, 2093056, PROT_NONE) = 0
mmap(0x7f47587e9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f47587e9000
mmap(0x7f47587eb000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f47587eb000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF21133>1200272"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4758230000
mprotect(0x7f47583cd000, 2093056, PROT_NONE) = 0
mmap(0x7f47585cc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7f47585cc000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d80000
arch_prctl(ARCH_SET_FS, 0x7f4759d811c0) = 0
mprotect(0x7f4759007000, 16384, PROT_READ) = 0
mprotect(0x7f47585cc000, 4096, PROT_READ) = 0
mprotect(0x7f47587e9000, 4096, PROT_READ) = 0
mprotect(0x7f47589fe000, 4096, PROT_READ) = 0
mprotect(0x7f4758c1b000, 4096, PROT_READ) = 0
mprotect(0x7f4759236000, 4096, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4759d70000
mprotect(0x7f47595b9000, 40960, PROT_READ) = 0
mprotect(0x7f47597d3000, 4096, PROT_READ) = 0
mprotect(0x7f47599f8000, 4096, PROT_READ) = 0
mprotect(0x7f475a008000, 4096, PROT_READ) = 0
mprotect(0x7f4759c27000, 4096, PROT_READ) = 0
munmap(0x7f4759dab000, 48784) = 0
set_tid_address(0x7f4759d81490) = 1491
set_robust_list(0x7f4759d814a0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f47585d5cb0, sa_mask=, sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f47585d5d50, sa_mask=, sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f47585e2890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=8192*1024}) = 0
brk(NULL) = 0x7fffc5980000
brk(0x7fffc59a1000) = 0x7fffc59a1000
futex(0x7f47595c607c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f47595c6088, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/mnt/d/Cpp/MyProject/myFile.bin", O_RDONLY) = 3
mmap(NULL, 1000, PROT_READ, MAP_SHARED, 3, 0) = 0x7f4759db6000
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 1), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "The mapped file buffer was NULL", 31) = 31
exit_group(-1) = ?
+++ exited with 255 +++
Note that when compiling for Windows the same problem arises so it's most likely a bug in my code or Boost.
c++ boost windows-subsystem-for-linux memory-mapped-files
c++ boost windows-subsystem-for-linux memory-mapped-files
edited Nov 23 at 12:38
asked Nov 22 at 13:30
BullyWiiPlaza
5,81424655
5,81424655
Can you provide thestracelog file from WSL? Commandstrace -ff -o test.txt your_command.
– Biswapriyo
Nov 22 at 19:31
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
Short compilable example and fullstraceadded now
– BullyWiiPlaza
Nov 23 at 12:39
add a comment |
Can you provide thestracelog file from WSL? Commandstrace -ff -o test.txt your_command.
– Biswapriyo
Nov 22 at 19:31
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
Short compilable example and fullstraceadded now
– BullyWiiPlaza
Nov 23 at 12:39
Can you provide the
strace log file from WSL? Command strace -ff -o test.txt your_command.– Biswapriyo
Nov 22 at 19:31
Can you provide the
strace log file from WSL? Command strace -ff -o test.txt your_command.– Biswapriyo
Nov 22 at 19:31
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
Short compilable example and full
strace added now– BullyWiiPlaza
Nov 23 at 12:39
Short compilable example and full
strace added now– BullyWiiPlaza
Nov 23 at 12:39
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
It turns out I passed bad parameters. Also, the offset must be a multiple of the page size. Here is the platform independent example source code demonstrating iteration over a file in chunks using mapped_file:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <sysinfoapi.h>
#endif
namespace filesystem = boost::filesystem;
namespace io_streams = boost::iostreams;
using std::ios;
using std::ifstream;
unsigned long long int get_page_size() {
#ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (unsigned long long int) sysInfo.dwPageSize;
#else
return (unsigned long long int) sysconf(_SC_PAGE_SIZE);
#endif
}
unsigned long long int get_file_size(const char *file_path) {
filesystem::path file{file_path};
auto generic_path = file.generic_path();
return filesystem::file_size(generic_path);
}
std::vector<char> read_bytes(const char *file_path,
unsigned long long int offset,
unsigned long long int length) {
io_streams::mapped_file_params parameters;
parameters.path = file_path;
parameters.length = static_cast<size_t>(length);
parameters.flags = io_streams::mapped_file::mapmode::readonly;
parameters.offset = static_cast<boost::iostreams::stream_offset>(offset);
boost::iostreams::mapped_file_source file;
file.open(parameters);
if (file.is_open()) {
auto buffer = file.data();
std::vector<char> vector_buffer;
for (auto buffer_index = 0; buffer_index < length; buffer_index++) {
auto byte = buffer[buffer_index];
vector_buffer.push_back(byte);
}
return vector_buffer;
} else {
printf("Failed to open filen");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv) {
#ifdef _WIN32
auto file_path = (const char *) R"(D:CppBoostTestingtest.bin)";
#else
auto file_path = (const char *) "/mnt/d/Cpp/BoostTesting/test.bin";
#endif
unsigned long long int offset = 0;
unsigned long long int page_size = get_page_size();
auto buffer_size = page_size;
auto total_length = get_file_size(file_path);
while (offset < total_length) {
auto remaining_bytes = total_length - offset;
if (buffer_size > remaining_bytes) {
buffer_size = remaining_bytes;
}
auto buffer = read_bytes(file_path, offset, buffer_size);
for (auto byte : buffer) {
printf("%i ", byte);
}
offset += buffer_size;
}
return EXIT_SUCCESS;
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432100%2fcannot-read-from-boostmapped-file-data-buffer-is-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
It turns out I passed bad parameters. Also, the offset must be a multiple of the page size. Here is the platform independent example source code demonstrating iteration over a file in chunks using mapped_file:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <sysinfoapi.h>
#endif
namespace filesystem = boost::filesystem;
namespace io_streams = boost::iostreams;
using std::ios;
using std::ifstream;
unsigned long long int get_page_size() {
#ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (unsigned long long int) sysInfo.dwPageSize;
#else
return (unsigned long long int) sysconf(_SC_PAGE_SIZE);
#endif
}
unsigned long long int get_file_size(const char *file_path) {
filesystem::path file{file_path};
auto generic_path = file.generic_path();
return filesystem::file_size(generic_path);
}
std::vector<char> read_bytes(const char *file_path,
unsigned long long int offset,
unsigned long long int length) {
io_streams::mapped_file_params parameters;
parameters.path = file_path;
parameters.length = static_cast<size_t>(length);
parameters.flags = io_streams::mapped_file::mapmode::readonly;
parameters.offset = static_cast<boost::iostreams::stream_offset>(offset);
boost::iostreams::mapped_file_source file;
file.open(parameters);
if (file.is_open()) {
auto buffer = file.data();
std::vector<char> vector_buffer;
for (auto buffer_index = 0; buffer_index < length; buffer_index++) {
auto byte = buffer[buffer_index];
vector_buffer.push_back(byte);
}
return vector_buffer;
} else {
printf("Failed to open filen");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv) {
#ifdef _WIN32
auto file_path = (const char *) R"(D:CppBoostTestingtest.bin)";
#else
auto file_path = (const char *) "/mnt/d/Cpp/BoostTesting/test.bin";
#endif
unsigned long long int offset = 0;
unsigned long long int page_size = get_page_size();
auto buffer_size = page_size;
auto total_length = get_file_size(file_path);
while (offset < total_length) {
auto remaining_bytes = total_length - offset;
if (buffer_size > remaining_bytes) {
buffer_size = remaining_bytes;
}
auto buffer = read_bytes(file_path, offset, buffer_size);
for (auto byte : buffer) {
printf("%i ", byte);
}
offset += buffer_size;
}
return EXIT_SUCCESS;
}
add a comment |
up vote
0
down vote
accepted
It turns out I passed bad parameters. Also, the offset must be a multiple of the page size. Here is the platform independent example source code demonstrating iteration over a file in chunks using mapped_file:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <sysinfoapi.h>
#endif
namespace filesystem = boost::filesystem;
namespace io_streams = boost::iostreams;
using std::ios;
using std::ifstream;
unsigned long long int get_page_size() {
#ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (unsigned long long int) sysInfo.dwPageSize;
#else
return (unsigned long long int) sysconf(_SC_PAGE_SIZE);
#endif
}
unsigned long long int get_file_size(const char *file_path) {
filesystem::path file{file_path};
auto generic_path = file.generic_path();
return filesystem::file_size(generic_path);
}
std::vector<char> read_bytes(const char *file_path,
unsigned long long int offset,
unsigned long long int length) {
io_streams::mapped_file_params parameters;
parameters.path = file_path;
parameters.length = static_cast<size_t>(length);
parameters.flags = io_streams::mapped_file::mapmode::readonly;
parameters.offset = static_cast<boost::iostreams::stream_offset>(offset);
boost::iostreams::mapped_file_source file;
file.open(parameters);
if (file.is_open()) {
auto buffer = file.data();
std::vector<char> vector_buffer;
for (auto buffer_index = 0; buffer_index < length; buffer_index++) {
auto byte = buffer[buffer_index];
vector_buffer.push_back(byte);
}
return vector_buffer;
} else {
printf("Failed to open filen");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv) {
#ifdef _WIN32
auto file_path = (const char *) R"(D:CppBoostTestingtest.bin)";
#else
auto file_path = (const char *) "/mnt/d/Cpp/BoostTesting/test.bin";
#endif
unsigned long long int offset = 0;
unsigned long long int page_size = get_page_size();
auto buffer_size = page_size;
auto total_length = get_file_size(file_path);
while (offset < total_length) {
auto remaining_bytes = total_length - offset;
if (buffer_size > remaining_bytes) {
buffer_size = remaining_bytes;
}
auto buffer = read_bytes(file_path, offset, buffer_size);
for (auto byte : buffer) {
printf("%i ", byte);
}
offset += buffer_size;
}
return EXIT_SUCCESS;
}
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
It turns out I passed bad parameters. Also, the offset must be a multiple of the page size. Here is the platform independent example source code demonstrating iteration over a file in chunks using mapped_file:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <sysinfoapi.h>
#endif
namespace filesystem = boost::filesystem;
namespace io_streams = boost::iostreams;
using std::ios;
using std::ifstream;
unsigned long long int get_page_size() {
#ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (unsigned long long int) sysInfo.dwPageSize;
#else
return (unsigned long long int) sysconf(_SC_PAGE_SIZE);
#endif
}
unsigned long long int get_file_size(const char *file_path) {
filesystem::path file{file_path};
auto generic_path = file.generic_path();
return filesystem::file_size(generic_path);
}
std::vector<char> read_bytes(const char *file_path,
unsigned long long int offset,
unsigned long long int length) {
io_streams::mapped_file_params parameters;
parameters.path = file_path;
parameters.length = static_cast<size_t>(length);
parameters.flags = io_streams::mapped_file::mapmode::readonly;
parameters.offset = static_cast<boost::iostreams::stream_offset>(offset);
boost::iostreams::mapped_file_source file;
file.open(parameters);
if (file.is_open()) {
auto buffer = file.data();
std::vector<char> vector_buffer;
for (auto buffer_index = 0; buffer_index < length; buffer_index++) {
auto byte = buffer[buffer_index];
vector_buffer.push_back(byte);
}
return vector_buffer;
} else {
printf("Failed to open filen");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv) {
#ifdef _WIN32
auto file_path = (const char *) R"(D:CppBoostTestingtest.bin)";
#else
auto file_path = (const char *) "/mnt/d/Cpp/BoostTesting/test.bin";
#endif
unsigned long long int offset = 0;
unsigned long long int page_size = get_page_size();
auto buffer_size = page_size;
auto total_length = get_file_size(file_path);
while (offset < total_length) {
auto remaining_bytes = total_length - offset;
if (buffer_size > remaining_bytes) {
buffer_size = remaining_bytes;
}
auto buffer = read_bytes(file_path, offset, buffer_size);
for (auto byte : buffer) {
printf("%i ", byte);
}
offset += buffer_size;
}
return EXIT_SUCCESS;
}
It turns out I passed bad parameters. Also, the offset must be a multiple of the page size. Here is the platform independent example source code demonstrating iteration over a file in chunks using mapped_file:
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <sysinfoapi.h>
#endif
namespace filesystem = boost::filesystem;
namespace io_streams = boost::iostreams;
using std::ios;
using std::ifstream;
unsigned long long int get_page_size() {
#ifdef _WIN32
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (unsigned long long int) sysInfo.dwPageSize;
#else
return (unsigned long long int) sysconf(_SC_PAGE_SIZE);
#endif
}
unsigned long long int get_file_size(const char *file_path) {
filesystem::path file{file_path};
auto generic_path = file.generic_path();
return filesystem::file_size(generic_path);
}
std::vector<char> read_bytes(const char *file_path,
unsigned long long int offset,
unsigned long long int length) {
io_streams::mapped_file_params parameters;
parameters.path = file_path;
parameters.length = static_cast<size_t>(length);
parameters.flags = io_streams::mapped_file::mapmode::readonly;
parameters.offset = static_cast<boost::iostreams::stream_offset>(offset);
boost::iostreams::mapped_file_source file;
file.open(parameters);
if (file.is_open()) {
auto buffer = file.data();
std::vector<char> vector_buffer;
for (auto buffer_index = 0; buffer_index < length; buffer_index++) {
auto byte = buffer[buffer_index];
vector_buffer.push_back(byte);
}
return vector_buffer;
} else {
printf("Failed to open filen");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv) {
#ifdef _WIN32
auto file_path = (const char *) R"(D:CppBoostTestingtest.bin)";
#else
auto file_path = (const char *) "/mnt/d/Cpp/BoostTesting/test.bin";
#endif
unsigned long long int offset = 0;
unsigned long long int page_size = get_page_size();
auto buffer_size = page_size;
auto total_length = get_file_size(file_path);
while (offset < total_length) {
auto remaining_bytes = total_length - offset;
if (buffer_size > remaining_bytes) {
buffer_size = remaining_bytes;
}
auto buffer = read_bytes(file_path, offset, buffer_size);
for (auto byte : buffer) {
printf("%i ", byte);
}
offset += buffer_size;
}
return EXIT_SUCCESS;
}
answered Nov 23 at 13:59
BullyWiiPlaza
5,81424655
5,81424655
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432100%2fcannot-read-from-boostmapped-file-data-buffer-is-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you provide the
stracelog file from WSL? Commandstrace -ff -o test.txt your_command.– Biswapriyo
Nov 22 at 19:31
@Biswapriyo: Thank you, good idea. I added the relevant strace results to the question
– BullyWiiPlaza
Nov 22 at 21:33
Short compilable example and full
straceadded now– BullyWiiPlaza
Nov 23 at 12:39