diff --git a/Makefile b/Makefile index 9084e73915..47e32c2723 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION -$(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif ### NOTES: @@ -47,7 +47,7 @@ ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') LEGACY_BUILD := 1 ifneq ($(CPLUSPLUS),201103L) - $(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) diff --git a/deps/Makefile b/deps/Makefile index 7fa0cec5b7..2b28c2cec3 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -32,7 +32,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) - $(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) diff --git a/docker-compose.yml b/docker-compose.yml index 659595eb27..dc1935562e 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "2.0" +version: "3.0" services: #################################################################################################### @@ -6,6 +6,7 @@ services: _build: image: none network_mode: bridge + privileged: true environment: - MAKE - MAKEOPT diff --git a/include/btree.h b/include/btree.h index 49310a2e44..bb22e0cf33 100644 --- a/include/btree.h +++ b/include/btree.h @@ -860,8 +860,8 @@ class btree : public Params::key_compare { typedef typename node_type::root_fields root_fields; typedef typename Params::is_key_compare_to is_key_compare_to; - friend class btree_internal_locate_plain_compare; - friend class btree_internal_locate_compare_to; + friend struct btree_internal_locate_plain_compare; + friend struct btree_internal_locate_compare_to; typedef typename if_< is_key_compare_to::value, btree_internal_locate_compare_to, diff --git a/include/gen_utils.h b/include/gen_utils.h index 95c1ec0107..4eb6e1c9c0 100644 --- a/include/gen_utils.h +++ b/include/gen_utils.h @@ -190,11 +190,11 @@ class PtrSizeArray { } }; -typedef struct { - void* data = nullptr; - size_t len = 0; +struct buffer_t { + void * data = nullptr; + size_t len = 0; size_t capacity = 0; -} buffer_t; +}; class FixedSizeQueue : public std::queue { private: diff --git a/lib/ClickHouse_Server.cpp b/lib/ClickHouse_Server.cpp index ca428c4934..db35d65635 100644 --- a/lib/ClickHouse_Server.cpp +++ b/lib/ClickHouse_Server.cpp @@ -840,9 +840,8 @@ void ClickHouse_Server_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t } if ( - ( - (query_no_space_length > 40) && - strncasecmp("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC",query_no_space,strlen("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC") == 0)) + (query_no_space_length > 40) && + (strncasecmp("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC", query_no_space, strlen("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC")) == 0) ) { l_free(query_length,query); query=l_strdup("SELECT 'utf8_general_ci' AS DEFAULT_COLLATION_NAME"); diff --git a/lib/Makefile b/lib/Makefile index c752ff254c..b94dd2fc65 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,7 +3,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION - $(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif DEPS_PATH := ../deps @@ -77,6 +77,10 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address # Force the disable of JEMALLOC, since ASAN isn't compatible. export NOJEMALLOC=1 + # workaroud ASAN limitation ASLR > 28bits + # https://github.com/google/sanitizers/issues/1716 + # sudo sysctl vm.mmap_rnd_bits=28 + $(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.) endif NOJEM := @@ -95,7 +99,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) -$(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) @@ -122,8 +126,8 @@ default: libproxysql.a .PHONY: default _OBJ_CXX := ProxySQL_GloVars.oo network.oo debug.oo configfile.oo Query_Cache.oo SpookyV2.oo MySQL_Authentication.oo gen_utils.oo sqlite3db.oo mysql_connection.oo MySQL_HostGroups_Manager.oo mysql_data_stream.oo MySQL_Thread.oo MySQL_Session.oo MySQL_Protocol.oo mysql_backend.oo Query_Processor.oo ProxySQL_Admin.oo ProxySQL_Config.oo ProxySQL_Restapi.oo MySQL_Monitor.oo MySQL_Logger.oo thread.oo MySQL_PreparedStatement.oo ProxySQL_Cluster.oo ClickHouse_Authentication.oo ClickHouse_Server.oo ProxySQL_Statistics.oo Chart_bundle_js.oo ProxySQL_HTTP_Server.oo ProxySQL_RESTAPI_Server.oo font-awesome.min.css.oo main-bundle.min.css.oo set_parser.oo MySQL_Variables.oo c_tokenizer.oo proxysql_utils.oo proxysql_coredump.oo proxysql_sslkeylog.oo \ - sha256crypt.oo \ - proxysql_find_charset.oo ProxySQL_Poll.oo + sha256crypt.oo \ + proxysql_find_charset.oo ProxySQL_Poll.oo OBJ_CXX := $(patsubst %,$(ODIR)/%,$(_OBJ_CXX)) HEADERS := ../include/*.h ../include/*.hpp diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index ec7c5dc9c9..4ecd467ea5 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -2026,7 +2026,7 @@ bool MySQL_HostGroups_Manager::commit( if (atoi(r->fields[4])!=atoi(r->fields[14])) { if (GloMTH->variables.hostgroup_manager_verbose) - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Changing weight for server %d:%s:%d (%s:%d) from %d (%d) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[4]) , mysrvc->weight , atoi(r->fields[14])); + proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Changing weight for server %d:%s:%d (%s:%d) from %d (%ld) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[4]) , mysrvc->weight , atoi(r->fields[14])); mysrvc->weight=atoi(r->fields[14]); } if (atoi(r->fields[5])!=atoi(r->fields[15])) { diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 864d37b5c4..3a1239b340 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -4370,18 +4370,18 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { } if (GloMTH->variables.ssl_p2s_ca == NULL && GloMTH->variables.ssl_p2s_capath == NULL) { - SPA->send_MySQL_ERR(&sess->client_myds->myprot, "'mysql-ssl_p2s_ca' and 'mysql-ssl_p2s_capath' have not been configured"); + SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"'mysql-ssl_p2s_ca' and 'mysql-ssl_p2s_capath' have not been configured"); break; } char msg[256]; uint64_t duration = 0ULL; if (SPA->ProxySQL_Test___CA_Certificate_Load_And_Verify(&duration, test_arg1, GloMTH->variables.ssl_p2s_ca, GloMTH->variables.ssl_p2s_capath)) { - sprintf(msg, "Took %llums in loading and verifying CA Certificate for %d times\n", duration, test_arg1); + sprintf(msg, "Took %lums in loading and verifying CA Certificate for %d times\n", duration, test_arg1); SPA->send_MySQL_OK(&sess->client_myds->myprot, msg); } else { - SPA->send_MySQL_ERR(&sess->client_myds->myprot, "Unable to verify CA Certificate"); + SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"Unable to verify CA Certificate"); } } break; @@ -9745,13 +9745,13 @@ void ProxySQL_Admin::stats___memory_metrics() { uint64_t prep_stmt_backend_mem_usage; GloMyStmt->get_memory_usage(prep_stmt_metadata_mem_usage, prep_stmt_backend_mem_usage); vn = (char*)"prepare_statement_metadata_memory"; - sprintf(bu, "%llu", prep_stmt_metadata_mem_usage); + sprintf(bu, "%lu", prep_stmt_metadata_mem_usage); query=(char*)malloc(strlen(a)+strlen(vn)+strlen(bu)+16); sprintf(query, a, vn, bu); statsdb->execute(query); free(query); vn = (char*)"prepare_statement_backend_memory"; - sprintf(bu, "%llu", prep_stmt_backend_mem_usage); + sprintf(bu, "%lu", prep_stmt_backend_mem_usage); query=(char*)malloc(strlen(a)+strlen(vn)+strlen(bu)+16); sprintf(query, a, vn, bu); statsdb->execute(query); @@ -15049,7 +15049,7 @@ bool ProxySQL_Admin::ProxySQL_Test___CA_Certificate_Load_And_Verify(uint64_t* du uint64_t t2 = monotonic_time(); SSL_CTX_free(ctx); *duration = ((t2/1000) - (t1/1000)); - proxy_info("Duration: %llums\n", *duration); + proxy_info("Duration: %lums\n", *duration); return true; } #endif //DEBUG diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index 27db42425c..b01c62f893 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -228,13 +228,13 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() : global.gr_bootstrap_ssl_key = nullptr; global.gr_bootstrap_ssl_mode = nullptr; global.ssl_keylog_enabled = false; - opt=new ez::ezOptionParser(); - opt->overview="High Performance Advanced Proxy for MySQL"; - opt->syntax="proxysql [OPTIONS]"; + opt = new ez::ezOptionParser(); + opt->overview = "High Performance Advanced Proxy for MySQL"; + opt->syntax = "proxysql [OPTIONS]"; std::string s = "\n\nProxySQL " ; - const char *build_year = __DATE__ + 7; + const char *build_year = &__DATE__[7]; s = s + "rev. " + PROXYSQL_VERSION + " -- " + __TIMESTAMP__ + "\nCopyright (C) 2013-" + string(build_year) + " ProxySQL LLC\nThis program is free and without warranty\n"; - opt->footer =s.c_str(); + opt->footer = s.c_str(); opt->add((const char *)"",0,0,0,(const char *)"Display usage instructions.",(const char *)"-h",(const char *)"-help",(const char *)"--help",(const char *)"--usage"); opt->add((const char *)"",0,0,0,(const char *)"Print version",(const char *)"-V",(const char *)"--version"); diff --git a/src/Makefile b/src/Makefile index 52a3d626ee..0d2e577cf2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION - $(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif CENTOSVER := Unknown @@ -109,7 +109,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) -$(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) @@ -140,6 +140,10 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address # Force the disable of JEMALLOC, since ASAN isn't compatible. export NOJEMALLOC=1 + # workaroud ASAN limitation ASLR > 28bits + # https://github.com/google/sanitizers/issues/1716 + # sudo sysctl vm.mmap_rnd_bits=28 + $(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.) endif ifeq ($(TEST_WITHASAN),1) WASAN += -DTEST_WITHASAN diff --git a/test/tap/tap/Makefile b/test/tap/tap/Makefile index 45097bbe83..b4650be943 100644 --- a/test/tap/tap/Makefile +++ b/test/tap/tap/Makefile @@ -3,7 +3,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION - $(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif @@ -42,7 +42,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) - $(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) @@ -50,6 +50,12 @@ STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPL WASAN := ifeq ($(WITHASAN),1) WASAN := -fsanitize=address + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 + # workaroud ASAN limitation ASLR > 28bits + # https://github.com/google/sanitizers/issues/1716 + # sudo sysctl vm.mmap_rnd_bits=28 + $(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.) endif OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WASAN) @@ -70,19 +76,19 @@ debug: libtap.a libtap.so ### helper targets command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c command_line.cpp $(IDIRS) $(OPT) + $(CXX) -fPIC -c command_line.cpp $(IDIRS) $(OPT) utils.o: utils.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c utils.cpp $(IDIRS) $(OPT) + $(CXX) -fPIC -c utils.cpp $(IDIRS) $(OPT) tap.o: tap.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c tap.cpp $(IDIRS) $(OPT) + $(CXX) -fPIC -c tap.cpp $(IDIRS) $(OPT) libtap.a: tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o libtap.so: libtap.a cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so - gcc -shared -o libtap.so -Wl,--whole-archive libtap.a -Wl,--no-whole-archive + $(CXX) -shared -o libtap.so -Wl,--whole-archive libtap.a -Wl,--no-whole-archive ### tap deps targets @@ -104,6 +110,7 @@ cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a: cd cpp-dotenv/static && tar -zxf ../cpp-dotenv-*.tar.gz cd cpp-dotenv/static/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch cd cpp-dotenv/static/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch + cd cpp-dotenv/static/cpp-dotenv && patch -p0 < ../../nm_clang_fix.patch cd cpp-dotenv/static/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Debug cd cpp-dotenv/static/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE} @@ -112,6 +119,7 @@ cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so: cd cpp-dotenv/dynamic && tar -zxf ../cpp-dotenv-*.tar.gz cd cpp-dotenv/dynamic/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch cd cpp-dotenv/dynamic/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch + cd cpp-dotenv/dynamic/cpp-dotenv && patch -p0 < ../../nm_clang_fix.patch cd cpp-dotenv/dynamic/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_RPATH="../tap:../../tap" -DCMAKE_BUILD_TYPE=Debug cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE} diff --git a/test/tap/tap/cpp-dotenv/nm_clang_fix.patch b/test/tap/tap/cpp-dotenv/nm_clang_fix.patch new file mode 100644 index 0000000000..2cf3067820 --- /dev/null +++ b/test/tap/tap/cpp-dotenv/nm_clang_fix.patch @@ -0,0 +1,12 @@ +diff --git src/dotenv.cpp src/dotenv.cpp +index 89bd3c1..1dcaf5a 100644 +--- src/dotenv.cpp ++++ src/dotenv.cpp +@@ -8,7 +8,6 @@ + + + using namespace std; +-using namespace dotenv; + + + dotenv::dotenv& dotenv::dotenv::load_dotenv(const string& dotenv_path, const bool overwrite, const bool interpolate) diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 422ead51cc..b1f73e5c0b 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -3,7 +3,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION - $(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif @@ -126,8 +126,8 @@ STATIC_LIBS := $(CITYHASH_LDIR)/libcityhash.a LIBCOREDUMPERAR := ifeq ($(UNAME_S),Linux) - LIBCOREDUMPERAR := $(COREDUMPER_LDIR)/libcoredumper.a - STATIC_LIBS += $(LIBCOREDUMPERAR) + LIBCOREDUMPERAR := $(COREDUMPER_LDIR)/libcoredumper.a + STATIC_LIBS += $(LIBCOREDUMPERAR) endif ### detect compiler support for c++11/17 @@ -135,7 +135,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) - $(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) @@ -148,6 +148,12 @@ endif WASAN := ifeq ($(WITHASAN),1) WASAN := -fsanitize=address -DTEST_WITHASAN + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 + # workaroud ASAN limitation ASLR > 28bits + # https://github.com/google/sanitizers/issues/1716 + # sudo sysctl vm.mmap_rnd_bits=28 + $(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.) endif OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" @@ -221,51 +227,49 @@ py-%: # $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LDIR)/libtap.so -o $@ galera_1_timeout_count: galera_1_timeout_count.cpp $(TAP_LDIR)/libtap.so - g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ + $(CXX) -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ galera_2_timeout_no_count: galera_2_timeout_no_count.cpp $(TAP_LDIR)/libtap.so - g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ + $(CXX) -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ generate_set_session_csv: generate_set_session_csv.cpp - g++ $< $(OPT) -o $@ + $(CXX) $< $(OPT) -o $@ aurora: aurora.cpp $(TAP_LDIR)/libtap.so - g++ -DTEST_AURORA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ + $(CXX) -DTEST_AURORA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ test_tokenizer-t: test_tokenizer-t.cpp $(TAP_LDIR)/libtap.so - g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ test_mysql_query_digests_stages-t: test_mysql_query_digests_stages-t.cpp $(TAP_LDIR)/libtap.so - g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ sqlite3-t: sqlite3-t.cpp $(TAP_LDIR)/libtap.so - g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ test_gtid_forwarding-t: test_gtid_forwarding-t.cpp $(TAP_LDIR)/libtap.so - g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ test_admin_prometheus_metrics_dump-t: test_admin_prometheus_metrics_dump-t.cpp $(TAP_LDIR)/libtap.so - g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ create_connection_annotation: test_connection_annotation-t.cpp $(TAP_LDIR)/libtap.so - g++ -DTEST_AURORA $< $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o $@ + $(CXX) -DTEST_AURORA $< $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o $@ setparser_test: setparser_test.cpp $(TAP_LDIR)/libtap.so $(RE2_PATH)/util/test.cc $(PROXYSQL_LDIR)/set_parser.cpp $(LIBPROXYSQLAR) $(LIBCOREDUMPERAR) - g++ $< $(RE2_PATH)/util/test.cc $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ + $(CXX) $< $(RE2_PATH)/util/test.cc $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ setparser_test2-t: setparser_test2 - rm setparser_test2-t || true ln -fs setparser_test2 setparser_test2-t setparser_test2: setparser_test2.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ + $(CXX) $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ setparser_test3-t: setparser_test3 - rm setparser_test3-t || true ln -fs setparser_test3 setparser_test3-t setparser_test3: setparser_test3.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ -DPARSERDEBUG $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ + $(CXX) -DPARSERDEBUG $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ CUSTOMARGS := -I$(TAP_IDIR) -I$(CURL_IDIR) -I$(SQLITE3_IDIR) -I$(PROXYSQL_IDIR) -I$(JSON_IDIR) -I$(SSL_IDIR) diff --git a/test/tap/tests/admin_show_table_status-t.cpp b/test/tap/tests/admin_show_table_status-t.cpp index 1e48e78471..0727e023c2 100644 --- a/test/tap/tests/admin_show_table_status-t.cpp +++ b/test/tap/tests/admin_show_table_status-t.cpp @@ -81,7 +81,7 @@ int main() { MYSQL_QUERY(proxysql_admin, query); MYSQL_RES* proxy_res = mysql_store_result(proxysql_admin); unsigned long rows = proxy_res->row_count; - ok(rows = 1 , "SHOW TABLE STATUS %s generated %lu row(s)", it->c_str(), rows); + ok(rows == 1 , "SHOW TABLE STATUS %s generated %lu row(s)", it->c_str(), rows); mysql_free_result(proxy_res); } free(query); diff --git a/test/tap/tests/reg_test_4072-show-warnings-t.cpp b/test/tap/tests/reg_test_4072-show-warnings-t.cpp index 3e22e70e19..b4f60e2e03 100644 --- a/test/tap/tests/reg_test_4072-show-warnings-t.cpp +++ b/test/tap/tests/reg_test_4072-show-warnings-t.cpp @@ -99,7 +99,7 @@ int main(int argc, char** argv) { unsigned long fetched_row_count = 0; - while (row = mysql_fetch_row(mysql_result)) { + while ((row = mysql_fetch_row(mysql_result))) { fetched_row_count++; usleep(10); } diff --git a/test/tap/tests/reg_test_4158_change_user-t.cpp b/test/tap/tests/reg_test_4158_change_user-t.cpp index 8b01a319c4..e7d7a86957 100644 --- a/test/tap/tests/reg_test_4158_change_user-t.cpp +++ b/test/tap/tests/reg_test_4158_change_user-t.cpp @@ -83,7 +83,7 @@ int run_funct_timeout(void *(*start_routine)(void *), int timeout) { diag("Waiting up to %d seconds", timeout); } } - if (tr =! 0) { + if (tr != 0) { return EXIT_FAILURE; } } else { diff --git a/test/tap/tests/test_cacert_load_and_verify_duration-t.cpp b/test/tap/tests/test_cacert_load_and_verify_duration-t.cpp index 46fbde802e..19da85d3d0 100644 --- a/test/tap/tests/test_cacert_load_and_verify_duration-t.cpp +++ b/test/tap/tests/test_cacert_load_and_verify_duration-t.cpp @@ -48,7 +48,7 @@ int main() { if (error_msg.find("Invalid test") != std::string::npos) { ok(true, "ProxySQL is not compiled in Debug mode. Skipping test"); } else { - fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, error_msg); + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, error_msg.c_str()); } } else { const std::string& msg = mysql_info(proxysql_admin); @@ -57,7 +57,7 @@ int main() { if (start_pos != std::string::npos && end_pos != std::string::npos) { uint64_t time = std::stoull(msg.substr(start_pos + 5, end_pos - (start_pos + 5))); - ok(time < 20000, "Total duration is '%llu ms' should be less than 20 Seconds", time); + ok(time < 20000, "Total duration is '%lu ms' should be less than 20 Seconds", time); } } mysql_close(proxysql_admin); diff --git a/test/tap/tests/test_change_user-t.cpp b/test/tap/tests/test_change_user-t.cpp index 5b1a842026..0f876234bc 100644 --- a/test/tap/tests/test_change_user-t.cpp +++ b/test/tap/tests/test_change_user-t.cpp @@ -187,7 +187,7 @@ int TestSet1(const CommandLine& cl, const char *plugin, bool test_ssl , bool tes } } } - close_connections; + close_connections(); } return 0; } diff --git a/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp b/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp index 68bce7954f..2eff27d901 100644 --- a/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp +++ b/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp @@ -95,7 +95,7 @@ std::map get_digest_stats_dummy_query(MYSQL* proxy_admin) { MYSQL_RES* res = mysql_store_result(proxy_admin); MYSQL_ROW row; - while (row = mysql_fetch_row(res)) { + while ((row = mysql_fetch_row(res))) { if (atoi(row[0]) == -1) stats["cache"] += atoi(row[1]); else diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index e800475998..b4060cdb18 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -3,7 +3,7 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION - $(error GIT_VERSION is not set) + $(error GIT_VERSION is not set) endif @@ -90,7 +90,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep ifneq ($(CPLUSPLUS),201703L) CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201103L) - $(error Compiler must support at least c++11) + $(error Compiler must support at least c++11) endif endif STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) @@ -103,6 +103,12 @@ endif WASAN := ifeq ($(WITHASAN),1) WASAN := -fsanitize=address + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 + # workaroud ASAN limitation ASLR > 28bits + # https://github.com/google/sanitizers/issues/1716 + # sudo sysctl vm.mmap_rnd_bits=28 + $(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.) endif OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,"../../tap" $(WGCOV) $(WASAN)