pcp
[Top] [All Lists]

Re: [pcp] pcp updates

To: markgw@xxxxxxx
Subject: Re: [pcp] pcp updates
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Sat, 24 Jan 2009 10:09:54 +1100
Cc: pcp@xxxxxxxxxxx
In-reply-to: <497A3E33.60201@xxxxxxx>
References: <1232744789.7851.2.camel@xxxxxxxxxxxxxxxxxxxxxxx> <497A3E33.60201@xxxxxxx>
Reply-to: kenj@xxxxxxxxxxxxxxxx
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);
> 

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