Open CrazyTennisFan opened 1 year ago
The PR for redis memory leak check is https://github.com/redis/redis/pull/9601
Confirmed repro
cd src && make all
make[1]: Entering directory '/home/jsully/keydb/src'
printf ' %b %b\n' "\033[34m"CC"\033[0m" "\033[33m"t_string.o"\033[0m";g++ -std=c++17 -pedantic -fno-rtti -D__STDC_FORMAT_MACROS -Wall -W -Wno-missing-field-initializers -Wno-address-of-packed-member -Wno-atomic-alignment -O0 -g -ggdb -fsanitize=address -DSANITIZE -fno-omit-frame-pointer -DMOTD -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/rocksdb/include/ -I../deps/concurrentqueue -I../deps/cpp-statsd-client/include/ -DUSE_OPENSSL -MMD -o t_string.o -c t_string.cpp
printf ' %b %b\n' "\033[34;1m"LINK"\033[0m" "\033[37;1m"keydb-server"\033[0m";g++ -fsanitize=address -g -ggdb -rdynamic -o keydb-server adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o t_nhash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o acl.o storage.o rdb-s3.o fastlock.o new.o tracking.o cron.o connection.o tls.o sha256.o motd_server.o timeout.o setcpuaffinity.o AsyncWorkQueue.o snapshot.o storage/teststorageprovider.o keydbutils.o StorageCache.o monotonic.o cli_common.o mt19937-64.o SnapshotPayloadParseState.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a -lm -lz -lcrypto -latomic -ldl -pthread -lrt -luuid -lcurl ../deps/hiredis/libhiredis_ssl.a -lssl -lcrypto
printf ' %b %b\n' "\033[34;1m"INSTALL"\033[0m" "\033[37;1m"keydb-sentinel"\033[0m";install keydb-server keydb-sentinel
printf ' %b %b\n' "\033[34;1m"INSTALL"\033[0m" "\033[37;1m"keydb-check-rdb"\033[0m";install keydb-server keydb-check-rdb
printf ' %b %b\n' "\033[34;1m"INSTALL"\033[0m" "\033[37;1m"keydb-check-aof"\033[0m";install keydb-server keydb-check-aof
echo ""
echo "Hint: It's a good idea to run 'make test' ;)"
echo ""
make[1]: Leaving directory '/home/jsully/keydb/src'
Ran make-n and confirmed we're sending fsanitize=address so something else must be off
If I add the codes in src/t_string.cpp as below:
void incrCommand(client *c) { sds buf = sdsempty(); incrDecrCommand(c,1); }
Then I compile redis using the following commands: make SANITIZER=address When I run the test case with redis 7 and redis latest version, I will get the following memory leak issue report:
*** [err]: Sanitizer error:
==2088887==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 4 byte(s) in 1 object(s) allocated from:
0 0x7f7dcaf2a867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
*** [err]: Sanitizer error:
==2089116==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 4 byte(s) in 1 object(s) allocated from:
0 0x7f6bf3d7a867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
*** [err]: Sanitizer error:
==2088636==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 20 byte(s) in 5 object(s) allocated from:
0 0x7f5ae13f0867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
SUMMARY: AddressSanitizer: 20 byte(s) leaked in 5 allocation(s).
However, when I compile the keydb with SANITIZE=address option as following commands:
make BUILD_TLS=yes NO_MOTD=yes NO_LICENSE_CHECK=yes ENABLE_FLASH=yes SANITIZE=address
and I run the test case, there is no any memory leak issue report