pcp
[Top] [All Lists]

Re: [pcp] pcp updates

To: kenj@xxxxxxxxxxxxxxxx
Subject: Re: [pcp] pcp updates
From: Mark Goodwin <markgw@xxxxxxx>
Date: Sat, 24 Jan 2009 10:29:31 +1100
Cc: pcp@xxxxxxxxxxx
In-reply-to: <1232752194.7851.4.camel@xxxxxxxxxxxxxxxxxxxxxxx>
Organization: SGI Engineering
References: <1232744789.7851.2.camel@xxxxxxxxxxxxxxxxxxxxxxx> <497A3E33.60201@xxxxxxx> <1232752194.7851.4.camel@xxxxxxxxxxxxxxxxxxxxxxx>
Reply-to: markgw@xxxxxxx
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
Reviewed and pushed to git://oss.sgi.com/pcp/pcp.git

Cheers


Ken McDonell wrote:
The classical C compiler had no notion of "read-only" data, so by some
time scale this is a "recent" invention ... 8^)>

But gcc has been doing this for sometime, so I'm guessing it has been
broken for a long time.  There is no QA coverage for this and I only
stumbled on in when I was playing with some C code coverage tools.

On Sat, 2009-01-24 at 09:01 +1100, Mark Goodwin wrote:
Ken McDonell wrote:
...
commit 00d426e80b1ef2faf98b7a5cc13f705acee3b053
Author: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date:   Fri Jan 16 17:09:43 2009 +1100

    Avoid updating pointer array allocated to static data.

    Exposed by newer gcc, need to change default (host) and alternate
    (archive) logic to set argv[] in kmServerExec().
Just curious how this ever worked with any (current or previous) compiler?
I thought const strings were placed in a read-only data segment, so the
assignment argv[1][1] = 'h' should have consistently faulted?

Cheers

diff --git a/src/libkmtime/src/client.c b/src/libkmtime/src/client.c
index 8f9e01d..43a8e5f 100644
--- a/src/libkmtime/src/client.c
+++ b/src/libkmtime/src/client.c
@@ -23,10 +23,12 @@ static int kmServerExec(int fd, int livemode)
  {
      char portname[32];
      int port, in, out;
-    char *argv[] = { "kmtime", "-a", NULL };
+    char *argv[] = { "kmtime", NULL, NULL };

      if (livemode)
-       argv[1][1] = 'h';       /* -h for live hosts */
+       argv[1] = "-h"; /* -h for live hosts */
+    else
+       argv[1] = "-a"; /* -a for archives */

      if (__pmProcessCreate(argv, &in, &out) == (pid_t)-1) {
         __pmCloseSocket(fd);



--

 Mark Goodwin                                  markgw@xxxxxxx
 Engineering Manager for XFS and PCP    Phone: +61-3-99631937
 SGI Australian Software Group           Cell: +61-4-18969583
-------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>