Casablanca test_runner使用std :: bad_alloc失败

时间:2018-06-09 18:34:12

标签: c++ rest casablanca cpprest-sdk

我在CentOS 7.5上有built Casablanca使用GCC 8.1.0和Boost 1.6.7(两者都是从源代码开始构建的)。

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()的第二个参数是size_t,但巨大,127Tb!为什么这样做,我该如何解决?我认为在编译过程中我遇到了什么问题?

1 个答案:

答案 0 :(得分:1)

当代操作系统:卡萨布兰卡可以→ 1 。 PCLinuxOS 2018,提升-1.64,g ++ -7.3。 ...... 2 。 Fedora 28,提升-1.66,g ++ -7.3。 ...... 3 。 Ubuntu 18.04,提升-1.65,g ++ -7.3。

Fedora 27,Debian 9 Stretch失败了:

cpprestsdk/Release/libs/websocketpp/websocketpp/transport/asio/security/tls.hpp:315:39: error: could not convert ‘boost::asio::ssl::error::make_error_code((boost::asio::ssl::error::stream_errors)1)’ from ‘boost::system::error_code’ to ‘std::error_code

CentOS 7.5:g ++ -4.8,-5.3无法使用。使用g ++ -6.3进行构建:测试显示“分段错误”。

CentOS 7.5:# yum install devtoolset-7-gcc-c++→gcc / g ++ -7.3.0

Boost-1.66(gcc-6.3.0):$ echo "using gcc : 63 : /usr/bin/g++63 ; " >> tools/build/src/user-config.jam && ./bootstrap.sh && ./b2

$ cd casablanca/Release/build/
$ scl enable devtoolset-7 bash && cmake3 ..
$ make
$ cd Binaries/
$ ./test_runner *_test.so 2>&1 | tee casablanca-test.log.txt
.
All test cases PASSED
Finished running all 790 tests

1600行:casablanca-test.log.txt https://www.dropbox.com/s/m9ohuws0b0r700j/casablanca-test.log.txt?dl=0