jvfan opened a new issue #1470: URL: https://github.com/apache/incubator-brpc/issues/1470
**Describe the bug (描述bug)** WSL2-Ubuntu20.04 下编译 bRPC 的示例 echo_c++ 成功,运行时报异常 src/tcmalloc.cc:332] Attempt to free invalid pointer;  **To Reproduce (复现方法)** 1. 安装 openssl、snappy、google-perftools、gtest 默认会安装 libxxx 到 /usr/local/lib 目录; ``` sudo apt-get install -y libsnappy-dev sudo apt-get install -y libgoogle-perftools-dev sudo apt-get install -y libgtest-dev ``` 2. 手动源码编译一些库 openssl 1.1.1k、gflags、protobuf、leveldb 全部安装 libxxx 到 /usr/local 目录,已经验证 protobuf 完全正常; 3. 添加 /usr/local/bin 到环境变量,并确保了以下条件 –/usr/include 目录中至少存在: * openssl/ssl.h * gflags/gflags.h * leveldb/db.h –/usr/local/lib 目录至少存在: * openssl 动态库 * gflags 动态库 * protobuf * leveldb 动态库 4. 执行 brpc 编译脚本如下: ``` sh config_brpc.sh --headers=/usr/include --libs=/usr/local/lib make ``` 5. 进入 example/echo_c++ 目录编译 以下是 Makefile 方式编译,cmake 方式也试过; ``` cd example/echo_c++ make ``` 7. 运行 echo_server ``` ./echo_server ``` ``` ./echo_client ``` **Expected behavior (期望行为)** echo_server 正常运行; echo_client 正常运行; **Versions (各种版本)** OS: WIN11-WSLg-Ubuntu20.04 Compiler: g++ 9.3.0 brpc: 0.9.7 protobuf: 3.17.3 **Additional context/screenshots (更多上下文/截图)** ``` ➜ echo_c++ make clean Cleaning ➜ echo_c++ make Generating echo.pb.cc Compiling echo.pb.o Compiling client.o Linking echo_client Compiling server.o In file included from ../../output/include/butil/resource_pool.h:89, from ../../output/include/brpc/socket.h:30, from ../../output/include/brpc/redis.h:32, from ../../output/include/brpc/server.h:43, from server.cpp:22: ../../output/include/butil/resource_pool_inl.h: In instantiation of ‘static butil::ResourcePool<T>* butil::ResourcePool<T>::singleton() [with T = brpc::Socket]’: ../../output/include/butil/resource_pool.h:118:38: required from ‘int butil::return_resource(butil::ResourceId<T>) [with T = brpc::Socket]’ ../../output/include/brpc/socket_inl.h:112:51: required from here ../../output/include/butil/resource_pool_inl.h:368:17: warning: ‘new’ of type ‘butil::ResourcePool<brpc::Socket>’ with extended alignment 64 [-Waligned-new=] 368 | p = new ResourcePool(); | ^~~~~~~~~~~~~~~~~~ ../../output/include/butil/resource_pool_inl.h:368:17: note: uses ‘void* operator new(std::size_t)’, which does not have an alignment parameter ../../output/include/butil/resource_pool_inl.h:368:17: note: use ‘-faligned-new’ to enable C++17 over-aligned new support Linking echo_server rm echo.pb.cc ➜ echo_c++ ➜ echo_c++ ./echo_server src/tcmalloc.cc:332] Attempt to free invalid pointer 0x5628779b1200 [1] 28488 abort ./echo_server ➜ echo_c++ ➜ echo_c++ ./echo_client src/tcmalloc.cc:332] Attempt to free invalid pointer 0x563ada41e200 [1] 28495 abort ./echo_client ➜ echo_c++ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
