This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with inheriting environment


> >> >The settings in the CYGWIN environment variable don't seem to be
> >> >inherited by child processes with latest CVS.
> >>
> >> This isn't enough information for me to go on.  You don't see
> >> "CYGWIN=whatever" in your child processes?  You say CYGWIN=tty and the
> >> CYGWIN environment variable says "tty" but you don't have a tty?  You
> >> say "CYGWIN=ntsec" but the enhanced permissions are not there?
> >I set CYGWIN=ntsec and the ehanced permissions are not there.
> >I set CYGWIN=check_case:strict and the case checking is relaxed.
> >The CYGWIN environment variable does not appear in the environ_init debug
> >output of the child process,
>
> There is no debug output from a child process which would show the CYGWIN
> environment variable.
>
> >and parse_options is not called.
>
> As I said, the CYGWIN environment variable is getting set for me.  I
> don't know how to explain what you're seeing.
>
> If I can't duplicate the problem, there is no way that I'll be able to
> debug it.
>
> This sounds similar to the problem that you reported before.
>
> If you can figure out why it's happening, I'd be happy to try to rectify
> the situation.  Setting a breakpoint in environ_init and inspecting the
> passed-in environment block should provide some clue about what is
> happening.
To duplicate, add the 'export' flag to your CYGWIN environment variable.

In _addenv, there is the line:
    envhere = cur_environ ()[offset] = (char *) (ENVMALLOC ? strdup (name) :
name);
ENVMALLOC is not set by default, so the entry in the environment table gets
set to the value of name. However when name goes out of scope in the calling
process, it's contents may be overwritten. Now the environment table entry
will be pointing to random memory.
Therefore, strdup must be called in all situations. Also, the original entry
should be free'ed to prevent a memory leak.

Chris



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]