I am running Redis 6.0.9 on MacOS Big Sur, when running 'make test', I got the following error: !!! WARNING The following tests failed:
*** [err]: Check for memory leaks (pid 4812) in tests/integration/rdb.tcl Expected '0 leaks' to equal or match 'leaks[4899]: [fatal] process 4812 has not started'
I don't know if this is a bug or not, I report it anyway. BTW, redis server and redis cli start Ok.
Comment From: oranagra
@jessezwd what hardware do you use? is it ARM or x86?
can you try Redis 6.2 or the unstable branch?
Comment From: jessezwd
I use x86. If Redis 6.0.9 works ok, I may not try Redis 6.2 currently. Thanks for your comment.
Comment From: yangbodong22011
*** [err]: Check for memory leaks (pid 4812) in tests/integration/rdb.tcl Expected '0 leaks' to equal or match 'leaks[4899]: [fatal] process 4812 has not started'
From the error log, I noticed that this is not a leak, but because your Redis process has exited before leaks $pid is executed, [fatal] process 4812 has not started
I found that on different versions of macOS, leaks $pid (when $pid no longer exists), the error message is different :
macOs High Sierra
➜ ~ leaks 55555
leaks[52095]: leaks cannot examine process 55555 (with name like '55555') because it no longer appears to be running.
MacOS Big Sur
➜ ~ leaks 55555
leaks[27180]: leaks cannot examine process 55555 (with name like '55555') because it no longer appears to be running.
leaks[27180]: [fatal] mach port for process 55555 not valid
Current code uses string match to determine whether the process exists, I think it can be modified to directly determine whether the process is alive.
diff --git a/tests/support/server.tcl b/tests/support/server.tcl
index ae93ad007..45861ebc2 100644
--- a/tests/support/server.tcl
+++ b/tests/support/server.tcl
@@ -51,8 +51,7 @@ proc kill_server config {
test "Check for memory leaks (pid $pid)" {
set output {0 leaks}
catch {exec leaks $pid} output
- if {[string match {*process does not exist*} $output] ||
- [string match {*cannot examine*} $output]} {
+ if {![is_alive $config]} {
# In a few tests we kill the server process.
set output "0 leaks"
}
Comment From: yangbodong22011
@jessezwd Hello, can you help transplant this commit code and test it on your computer?
diff --git a/tests/support/server.tcl b/tests/support/server.tcl
index 1cddb7068..77ba31d84 100644
--- a/tests/support/server.tcl
+++ b/tests/support/server.tcl
@@ -50,11 +50,17 @@ proc kill_server config {
tags {"leaks"} {
test "Check for memory leaks (pid $pid)" {
set output {0 leaks}
- catch {exec leaks $pid} output
- if {[string match {*process does not exist*} $output] ||
- [string match {*cannot examine*} $output]} {
- # In a few tests we kill the server process.
- set output "0 leaks"
+ catch {exec leaks $pid} output option
+ # In a few tests we kill the server process, so leaks will not find it.
+ # It'll exits with exit code >1 on error, so we ignore these.
+ if {[dict exists $option -errorcode]} {
+ set details [dict get $option -errorcode]
+ if {[lindex $details 0] eq "CHILDSTATUS"} {
+ set status [lindex $details 2]
+ if {$status > 1} {
+ set output "0 leaks"
+ }
+ }
}
set output
} {*0 leaks*}