|
From: <sv...@va...> - 2005-12-19 21:28:04
|
Author: njn
Date: 2005-12-19 21:27:58 +0000 (Mon, 19 Dec 2005)
New Revision: 5384
Log:
Fix for bug #117096.
Modified:
trunk/coregrind/m_main.c
trunk/docs/internals/3_1_BUGSTATUS.txt
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-12-19 19:40:58 UTC (rev 5383)
+++ trunk/coregrind/m_main.c 2005-12-19 21:27:58 UTC (rev 5384)
@@ -1027,8 +1027,11 @@
=20
static Bool process_cmd_line_options( UInt* client_auxv, const char* too=
lname )
{
+ // VG_(clo_log_fd) is used by all the messaging. It starts as 2 (std=
err)
+ // and we cannot change it until we know what we are changing it to i=
s
+ // ok. So we have tmp_log_fd to hold the tmp fd prior to that point.
SysRes sres;
- Int i, eventually_log_fd;
+ Int i, tmp_log_fd;
Int toolname_len =3D VG_(strlen)(toolname);
enum {
VgLogTo_Fd,
@@ -1038,7 +1041,7 @@
} log_to =3D VgLogTo_Fd; // Where is logging output to be sent?
=20
/* log to stderr by default, but usage message goes to stdout */
- eventually_log_fd =3D 2;=20
+ tmp_log_fd =3D 2;=20
=20
/* Check for sane path in ./configure --prefix=3D... */
if (VG_LIBDIR[0] !=3D '/')=20
@@ -1147,7 +1150,7 @@
else if (VG_CLO_STREQN(9, arg, "--log-fd=3D")) {
log_to =3D VgLogTo_Fd;
VG_(clo_log_name) =3D NULL;
- eventually_log_fd =3D (Int)VG_(atoll)(&arg[9]);
+ tmp_log_fd =3D (Int)VG_(atoll)(&arg[9]);
}
=20
else if (VG_CLO_STREQN(11, arg, "--log-file=3D")) {
@@ -1322,7 +1325,6 @@
=20
case VgLogTo_Fd:=20
vg_assert(VG_(clo_log_name) =3D=3D NULL);
- VG_(clo_log_fd) =3D eventually_log_fd;
break;
=20
case VgLogTo_File: {
@@ -1361,13 +1363,11 @@
seqtxt );
=20
// EXCL: it will fail with EEXIST if the file already exists=
.
- sres
- =3D VG_(open)(logfilename,=20
- VKI_O_CREAT|VKI_O_WRONLY|VKI_O_EXCL|VKI_O_TRUNC,=20
- VKI_S_IRUSR|VKI_S_IWUSR);
+ sres =3D VG_(open)(logfilename,=20
+ VKI_O_CREAT|VKI_O_WRONLY|VKI_O_EXCL|VKI_O_T=
RUNC,=20
+ VKI_S_IRUSR|VKI_S_IWUSR);
if (!sres.isError) {
- eventually_log_fd =3D sres.val;
- VG_(clo_log_fd) =3D VG_(safe_fd)(eventually_log_fd);
+ tmp_log_fd =3D sres.val;
break; /* for (;;) */
} else {
// If the file already existed, we try the next name. If=
it
@@ -1389,13 +1389,11 @@
vg_assert(VG_(clo_log_name) !=3D NULL);
vg_assert(VG_(strlen)(VG_(clo_log_name)) <=3D 900); /* paranoia=
*/
=20
- sres
- =3D VG_(open)(VG_(clo_log_name),
- VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,=20
- VKI_S_IRUSR|VKI_S_IWUSR);
+ sres =3D VG_(open)(VG_(clo_log_name),
+ VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,=20
+ VKI_S_IRUSR|VKI_S_IWUSR);
if (!sres.isError) {
- eventually_log_fd =3D sres.val;
- VG_(clo_log_fd) =3D VG_(safe_fd)(eventually_log_fd);
+ tmp_log_fd =3D sres.val;
} else {
VG_(message)(Vg_UserMsg,=20
"Can't create/open log file '%s'; giving up!",=20
@@ -1410,8 +1408,8 @@
case VgLogTo_Socket: {
vg_assert(VG_(clo_log_name) !=3D NULL);
vg_assert(VG_(strlen)(VG_(clo_log_name)) <=3D 900); /* paranoia=
*/
- eventually_log_fd =3D VG_(connect_via_socket)( VG_(clo_log_name=
) );
- if (eventually_log_fd =3D=3D -1) {
+ tmp_log_fd =3D VG_(connect_via_socket)( VG_(clo_log_name) );
+ if (tmp_log_fd =3D=3D -1) {
VG_(message)(Vg_UserMsg,=20
"Invalid --log-socket=3Dipaddr or --log-socket=3Dipaddr:p=
ort spec");=20
VG_(message)(Vg_UserMsg,=20
@@ -1420,7 +1418,7 @@
"--log-socket=3D");
/*NOTREACHED*/
}
- if (eventually_log_fd =3D=3D -2) {
+ if (tmp_log_fd =3D=3D -2) {
VG_(message)(Vg_UserMsg,=20
"valgrind: failed to connect to logging server '%s'.",
VG_(clo_log_name) );=20
@@ -1430,9 +1428,9 @@
"" );
/* We don't change anything here. */
vg_assert(VG_(clo_log_fd) =3D=3D 2);
+ tmp_log_fd =3D 2;
} else {
- vg_assert(eventually_log_fd > 0);
- VG_(clo_log_fd) =3D eventually_log_fd;
+ vg_assert(tmp_log_fd > 0);
VG_(logging_to_socket) =3D True;
}
break;
@@ -1450,17 +1448,20 @@
/*NOTREACHED*/
}
=20
- // Move log_fd into the safe range, so it doesn't conflict with any a=
pp fds.
- // XXX: this is more or less duplicating the behaviour of the calls t=
o
- // VG_(safe_fd)() above, although this does not close the original fd=
.
- // Perhaps the VG_(safe_fd)() calls above should be removed, and this
- // code should be replaced with a call to VG_(safe_fd)(). --njn
- eventually_log_fd =3D VG_(fcntl)(VG_(clo_log_fd), VKI_F_DUPFD, VG_(fd=
_hard_limit));
- if (eventually_log_fd < 0)
- VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd into=
safe range");
- else {
- VG_(clo_log_fd) =3D eventually_log_fd;
- VG_(fcntl)(VG_(clo_log_fd), VKI_F_SETFD, VKI_FD_CLOEXEC);
+ if (tmp_log_fd >=3D 0) {
+ // Move log_fd into the safe range, so it doesn't conflict with an=
y app fds.
+ tmp_log_fd =3D VG_(fcntl)(tmp_log_fd, VKI_F_DUPFD, VG_(fd_hard_lim=
it));
+ if (tmp_log_fd < 0) {
+ VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd i=
nto safe range, using stderr");
+ VG_(clo_log_fd) =3D 2; // stderr
+ } else {
+ VG_(clo_log_fd) =3D tmp_log_fd;
+ VG_(fcntl)(VG_(clo_log_fd), VKI_F_SETFD, VKI_FD_CLOEXEC);
+ }
+ } else {
+ // If they said --log-fd=3D-1, don't print anything. Plausible fo=
r use in
+ // regression testing suites that use client requests to count err=
ors.
+ VG_(clo_log_fd) =3D tmp_log_fd;
}
=20
if (VG_(clo_n_suppressions) < VG_CLO_MAX_SFILES-1 &&
Modified: trunk/docs/internals/3_1_BUGSTATUS.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/docs/internals/3_1_BUGSTATUS.txt 2005-12-19 19:40:58 UTC (rev 5=
383)
+++ trunk/docs/internals/3_1_BUGSTATUS.txt 2005-12-19 21:27:58 UTC (rev 5=
384)
@@ -29,3 +29,4 @@
v5368 pending n-i-bz More space for debugger cmd line (Dan Thale=
r)
v5378/80 v5379/81 n-i-bz Clarified leak checker output message
v5382 pending n-i-bz AshleyP's --gen-suppressions output fix
+v5384 wontfix 117096 Weird errors when --log-fd=3D has invalid v=
alue
|