Closed yushimeng closed 3 weeks ago
抱歉,我对交叉编译不是很了解,之前没试过通过交叉编译来安装redis-plus-plus。从你的这个堆栈信息来看,似乎在创建ConnectionPool的时候出问题了(这个堆栈信息也没有看出有访问空指针之类的问题),但这个类的构造函数只是对数据乘员的拷贝初始化,没有其它操作,应该不会有问题。感觉像是交叉编译导致了一些内存问题。你可以试试交叉编译一个与redis-plus-plus无关的,但存在shared_ptr和自定义类的程序,看看是不是交叉编译指令的问题。
可能是依赖库的问题, 我重新编译hiredis和redisplusplus, 符合预期, 不崩溃了.
Describe the bug 在线上容器内编译生成的程序运行正常, 但是本地交叉编译后放在线上容器内运行崩溃. 线上宿主机arm centos, 容器 ubuntu,
To Reproduce
include
include
include
include <sw/redis++/redis++.h>
using namespace std; using namespace sw::redis;
int redis_test() { ConnectionOptions connection_options; connection_options.host = "172.18.10.7"; // Required. connection_options.port = 6301; // Optional. The default port is 6379. connection_options.password = "7Un9oVRyVZ"; // Optional. No password by default. connection_options.db = 0; // Optional. Use the 0th database by default.
} Expected behavior crash : (gdb) bt
0 0x0000aaaaab41f020 in sw::redis::ConnectionPool::ConnectionPool(sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&) ()
1 0x0000aaaaaac0933c in __gnu_cxx::new_allocator::construct<sw::redis::ConnectionPool, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> (
2 std::allocator_traits<std::allocator >::construct<sw::redis::ConnectionPool, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> (__a=...,
3 std::shared_ptr<sw::redis::ConnectionPool, (__gnu_cxx::_Lock_policy)2>::shared_ptr<std::allocator, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> (a=..., tag=..., this=)
4 std::shared_ptr::shared_ptr<std::allocator, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> (a=..., tag=...,
5 std::allocate_shared<sw::redis::ConnectionPool, std::allocator, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> (__a=...)
6 std::make_shared<sw::redis::ConnectionPool, sw::redis::ConnectionPoolOptions const&, sw::redis::ConnectionOptions const&> () at /usr/aarch64-linux-gnu/include/c++/7/bits/shared_ptr.h:707
7 gnu_cxx::new_allocator::construct<sw::redis::Redis, sw::redis::ConnectionOptions&> (this=, p=0xaaaaab700990, pool_opts=..., connection_opts=...,
8 std::allocator_traits<std::allocator >::construct<sw::redis::Redis, sw::redis::C---Type to continue, or q to quit---
onnectionOptions&> (a=..., p=0xaaaaab700990) at /usr/aarch64-linux-gnu/include/c++/7/bits/alloc_traits.h:475
9 std::shared_ptr<sw::redis::Redis, (__gnu_cxx::_Lock_policy)2>::shared_ptr<std::allocator, sw::redis::ConnectionOptions&> (a=..., tag=..., this=)
10 std::shared_ptr::shared_ptr<std::allocator, sw::redis::ConnectionOptions&> (a=..., tag=..., this=)
11 std::allocate_shared<sw::redis::Redis, std::allocator, sw::redis::ConnectionOptions&> (__a=...) at /usr/aarch64-linux-gnu/include/c++/7/bits/shared_ptr.h:691
12 std::make_shared<sw::redis::Redis, sw::redis::ConnectionOptions&> ()
13 RedisPush::RedisPush (this=0xaaaaab70afc0, host=..., port=, password=...,
Environment:
Additional context Add any other context about the problem here.