Skip to content

Commit

Permalink
fix asan
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Dec 8, 2023
1 parent 88662e3 commit 47adb77
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export REPORT_DIR="$ROOT/test_report"
export THIRDPARTY_ROOT=$ROOT/thirdparty
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/server:${BUILD_LATEST_DIR}/output/lib:${THIRDPARTY_ROOT}/output/lib:${LD_LIBRARY_PATH}
# Disable AddressSanitizerOneDefinitionRuleViolation, see https://github.com/google/sanitizers/issues/1017 for details.
export ASAN_OPTIONS=detect_odr_violation=0
export ASAN_OPTIONS=detect_odr_violation=0:abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1
# See https://github.com/gperftools/gperftools/wiki/gperftools'-stacktrace-capturing-methods-and-their-issues.
# Now we choose libgcc, because of https://github.com/apache/incubator-pegasus/issues/1685.
export TCMALLOC_STACKTRACE_METHOD=libgcc # Can be generic_fp, generic_fp_unsafe, libunwind or libgcc
Expand Down
23 changes: 13 additions & 10 deletions src/runtime/rpc/rpc_host_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "runtime/rpc/rpc_host_port.h"
#include "utils/error_code.h"
#include "utils/fixed_size_buffer_pool.h"
#include "utils/ports.h"
#include "utils/safe_strerror_posix.h"
#include "utils/string_conv.h"
#include "utils/utils.h"
Expand Down Expand Up @@ -72,27 +73,29 @@ host_port::host_port(std::string host, uint16_t port)

bool host_port::from_string(const std::string s)
{
std::string ip_port = s;
auto pos = ip_port.find_last_of(':');
auto pos = s.find_last_of(':');
if (pos == std::string::npos) {
return false;
}
std::string host = ip_port.substr(0, pos);
std::string port = ip_port.substr(pos + 1);
_host = s.substr(0, pos);
std::string port = s.substr(pos + 1);

// check port
unsigned int port_num;
if (!internal::buf2unsigned(port, port_num) || port_num > UINT16_MAX) {
if (!internal::buf2unsigned(port, _port) || _port > UINT16_MAX) {
return false;
}

if (rpc_address::ipv4_from_host(host.c_str()) == 0) {
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
AddrInfo result;
auto err_code = GetAddrInfo(_host, hints, &result);

if (dsn_unlikely(!err_code.ok())) {
return false;
}

_type = HOST_TYPE_IPV4;
_host = host;
_port = port_num;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "gtest/gtest.h"
#include "include/pegasus/client.h"
#include "include/pegasus/error.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_host_port.h"
#include "test/function_test/utils/test_util.h"
#include "utils/error_code.h"
Expand Down
2 changes: 0 additions & 2 deletions src/test/function_test/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ rpc_timeout_milliseconds = 5000
lb_interval_ms = 3000

[pegasus.clusters]
; TODO(yingchun): leave only 1 cluster config
mycluster = @LOCAL_HOSTNAME@:34601,@LOCAL_HOSTNAME@:34602,@LOCAL_HOSTNAME@:34603
onebox = @LOCAL_HOSTNAME@:34601,@LOCAL_HOSTNAME@:34602,@LOCAL_HOSTNAME@:34603
single_master_cluster = @LOCAL_HOSTNAME@:34601

Expand Down
2 changes: 1 addition & 1 deletion src/test/function_test/utils/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void test_util::SetUp()

ddl_client_ = std::make_shared<replication_ddl_client>(meta_list_);
ASSERT_TRUE(ddl_client_ != nullptr);
ddl_client_->set_meta_servers_leader();
ddl_client_->set_max_wait_app_ready_secs(120);
ddl_client_->set_meta_servers_leader();

dsn::error_code ret =
ddl_client_->create_app(app_name_, "pegasus", partition_count_, 3, create_envs_, false);
Expand Down
2 changes: 1 addition & 1 deletion src/test/function_test/utils/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class test_util : public ::testing::Test
{
public:
test_util(std::map<std::string, std::string> create_envs = {},
std::string cluster_name = "mycluster");
std::string cluster_name = "onebox");
virtual ~test_util();

static void SetUpTestCase();
Expand Down

0 comments on commit 47adb77

Please sign in to comment.