Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core dump when using RedisSyncClient::command #77

Open
SnowfallDan opened this issue May 4, 2020 · 0 comments
Open

Core dump when using RedisSyncClient::command #77

SnowfallDan opened this issue May 4, 2020 · 0 comments

Comments

@SnowfallDan
Copy link

hi

i am facing a core dump when call RedisSyncClient::command() function.

My env :
boost: 1.7.0
gcc: 6.3.0
os: centos 7.6

gdb's bt:
(gdb) bt
#0 0x00007f46f5e1295f in __memmove_ssse3_back () from /lib64/libc.so.6
#1 0x000000000055151d in redisclient::RedisClientImpl::syncReadResponse(boost::posix_time::time_duration const&, boost::system::error_code&) ()
#2 0x000000000055137f in redisclient::RedisClientImpl::doSyncCommand(std::deque<redisclient::RedisBuffer, std::allocatorredisclient::RedisBuffer > const&, boost::posix_time::time_duration const&, boost::system::error_code&) ()
#3 0x0000000000552028 in redisclient::RedisSyncClient::command(std::string, std::deque<redisclient::RedisBuffer, std::allocatorredisclient::RedisBuffer >, boost::system::error_code&) ()
#4 0x0000000000551eef in redisclient::RedisSyncClient::command(std::string, std::deque<redisclient::RedisBuffer, std::allocatorredisclient::RedisBuffer >)()

Source code:
`
long get_update_remain(const void *sql_ctx, const void *redis_ctx, const char *user_id, unsigned int flow_size)
{
long remain_k = 0;
string key_remain_size = string(KEY_ORDER_REMAIN_SIZE) + user_id;

assert(redis_ctx);
auto redis = (redisclient::RedisSyncClient *) redis_ctx;

redisclient::RedisValue result;
result = redis->command("GET", {key_remain_size});
string res = result.toString();
if (result.isError() || result.toString().empty())
{
    printf("GET error, key[%s], result[%s]\n",
           key_remain_size.c_str(), result.toString().c_str());

    //select new order
    if (!select_order(sql_ctx, redis_ctx, user_id))
    {
        return 0;
    }
}
else
{
    try
    {
        printf("%s\n", result.toString().c_str());
        remain_k = std::stol(result.toString());
        printf("before DECRBY remain_k is %ld\n", remain_k);
    }
    catch (...)
    {
        printf("error");
    }
}

if(flow_size == 0)
    return remain_k;

//Redis Dec
result = redis->command("DECRBY", {key_remain_size, std::to_string(flow_size/1024)});
if (result.isError() || !result.isInt())
{
    printf("DECRBY key=%s error\n", key_remain_size.c_str());
    return 0;
}
remain_k = (long)result.toInt();
printf("after DECRBY remain_k is %ld\n", remain_k);

if (remain_k<=0)
    unset_order(sql_ctx, redis_ctx, user_id);

return remain_k;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant