我已经使用 GCC 8.1.0 和 Boost 1.6.7 在 CentOS 7.5 上构建了 Casablanca (之前都从源代码构建)。
git clone https://github.com/Microsoft/cpprestsdk.git casablanca
cd casablanca/Release
mkdir build.debug
cd build.debug
cmake3 .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/local/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ -DWERROR=OFF
make
但是测试失败:
cd Binaries
./test_runner *_test.so
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
检查strace
我看到
mmap(NULL, 140728712380416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
brk(NULL) = 0x134e000
brk(0x7ffdf61f8000) = 0x134e000
mmap(NULL, 140728712511488, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7fb46b842000
munmap(0x7fb46b842000, 8118272) = 0
munmap(0x7fb470000000, 58990592) = 0
mprotect(0x7fb46c000000, 135168, PROT_READ|PROT_WRITE) = 0
mmap(NULL, 140728712380416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
futex(0x7fb47d8d91a0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
的第二个参数mmap()
是 a size_t
,但它很大,127Tb!为什么会这样,我该如何解决?我想我在编译过程中出了点问题?