[patch] Bug report and patch for strace's -v option with -s0(1) (Zhaolei)
Zhaolei
zhaolei at cn.fujitsu.com
Wed Jul 18 09:15:24 UTC 2007
Hi, everyone
I found a bug of strace when I was using strace with -v -s0(s1) option.
# strace-4.5.15/strace -s0 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", [, ...], [, ...]) = 0
# strace-4.5.15/strace -s1 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", [, ...], [, ...]) = 0
# strace-4.5.15/strace -s2 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["ec"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HO"..., "SH"..., "TE"..., "HI"..., "SS"..., "QT"..., "SS"..., "US"..., "LS"..., "KD"..., "PA"..., "MA"..., "PW"..., "IN"..., "LA"..., "SS"..., "HO"..., "SH"..., "LO"..., "SS"..., "LE"..., "G_"..., "_="...]) = 0
# strace-4.5.15/strace -s3 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["ech"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HOS"..., "SHE"..., "TER"..., "HIS"..., "SSH"..., "QTD"..., "SSH"..., "USE"..., "LS_"..., "KDE"..., "PAT"..., "MAI"..., "PWD"..., "INP"..., "LAN"..., "SSH"..., "HOM"..., "SHL"..., "LOG"..., "SSH"..., "LES"..., "G_B"..., "_=s"...]) = 0
# strace-4.5.15/strace -s4 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["echo"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HOST"..., "SHEL"..., "TERM"..., "HIST"..., "SSH_"..., "QTDI"..., "SSH_"..., "USER"..., "LS_C"..., "KDED"..., "PATH"..., "MAIL"..., "PWD="..., "INPU"..., "LANG"..., "SSH_"..., "HOME"..., "SHLV"..., "LOGN"..., "SSH_"..., "LESS"..., "G_BR"..., "_=st"...]) = 0
The bug can be fixed with the following patch:
This patch make value of max at lease to be 1 to assure that program always running into "for()".
In addition, fixs another problem: value of cp is not initialized before use in old code when
value of -s is 0 or 1.
Signed-off-by: "Zhaolei" zhaolei at cn.fujitsu.com
--- process.c 2007-07-12 13:53:51.000000000 +0800
+++ process.c.new 2007-07-12 13:54:18.000000000 +0800
@@ -1679,7 +1679,7 @@ long addr;
{
char *cp;
char *sep;
- int max = max_strlen / 2;
+ int max = max_strlen / 2 + 1;
for (sep = ""; --max >= 0; sep = ", ") {
if (!abbrev(tcp))
The following is result outputted by the patched strace:
# strace-4.5.15/strace -s0 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", [""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""...], [""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""..., ""...]) = 0
# strace-4.5.15/strace -s1 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["e"..., "0"..., "1"..., "2"..., "3"..., "4"..., "5"..., "6"..., "7"..., "8"..., "9"...], ["H"..., "S"..., "T"..., "H"..., "S"..., "Q"..., "S"..., "U"..., "L"..., "K"..., "P"..., "M"..., "P"..., "I"..., "L"..., "S"..., "H"..., "S"..., "L"..., "S"..., "L"..., "G"..., "_"...]) = 0
# strace-4.5.15/strace -s2 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["ec"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HO"..., "SH"..., "TE"..., "HI"..., "SS"..., "QT"..., "SS"..., "US"..., "LS"..., "KD"..., "PA"..., "MA"..., "PW"..., "IN"..., "LA"..., "SS"..., "HO"..., "SH"..., "LO"..., "SS"..., "LE"..., "G_"..., "_="...]) = 0
# strace-4.5.15/strace -s3 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["ech"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HOS"..., "SHE"..., "TER"..., "HIS"..., "SSH"..., "QTD"..., "SSH"..., "USE"..., "LS_"..., "KDE"..., "PAT"..., "MAI"..., "PWD"..., "INP"..., "LAN"..., "SSH"..., "HOM"..., "SHL"..., "LOG"..., "SSH"..., "LES"..., "G_B"..., "_=s"...]) = 0
# strace-4.5.15/strace -s4 -v echo 0 1 2 3 4 5 6 7 8 9 2>&1 1>/dev/null | grep "execve("
execve("/bin/echo", ["echo"..., "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ["HOST"..., "SHEL"..., "TERM"..., "HIST"..., "SSH_"..., "QTDI"..., "SSH_"..., "USER"..., "LS_C"..., "KDED"..., "PATH"..., "MAIL"..., "PWD="..., "INPU"..., "LANG"..., "SSH_"..., "HOME"..., "SHLV"..., "LOGN"..., "SSH_"..., "LESS"..., "G_BR"..., "_=st"...]) = 0
Regards
Zhaolei
More information about the Strace-devel
mailing list