Re: seg-vios from gcc program at execv() on Windows XP

2004-10-01 Thread Igor Pechtchanski
On Thu, 30 Sep 2004, Richard Troy wrote:

 On Thu, 30 Sep 2004, Igor Pechtchanski wrote:

   Note that the code is _rock_solid_ on Linux/Unix/Mac OSX, and on all
   earlier versions of Windows we've ever tried it on. We've _never_ seen it
   seg-vio before.
 
  Please provide a complete (hopefully simple) testcase, along with the
  compilation flags, etc.  In particular, it'd be interesting to see how
  nargv is allocated, etc.  I suspect you're not placing a NULL at the end
  of the argument list, and Cygwin and Linux allocate nargv differently (so
  that on Linux, nargv just happens to have zeroed memory after it).

 Almost; right issue, wrong problem. It turned out not that there wasn't a
 terminating NULL but that there was an extra one, one past where it
 should have been! This kind of problem is, apparently, _very_ easy to
 overlook and I guess we just got away with it in the past. -shrug-

Hmm, an extra NULL shouldn't have any effect -- execv stops at the first
one, IIRC.  I wasn't dismissing the possibility of a bug in Cygwin, simply
wanted to make sure that the code that exhibited the problem was correct.
I realize that you now have the issue fixed (or worked around), but if
you're still willing to pursue this to help Cygwin get better, please
check with SUS on the semantics of all the system calls used, and if you
can construct a testcase that should work correctly but doesn't, please
resubmit the bug report (with the complete testcase).

 I want to thank you for taking the time to reply, Igor. I was awfully
 stressed out about it.

Glad it helped.

 Even though it wasn't really a Cygwin problem, you were supportive and I
 appreciagte it.

We don't know yet that it wasn't.  From your description of the fix, it
seemed that your original code should have worked.  That's why I asked for
the testcase.

   (BTW ping and dig utilities would be nice!)
 
  FWIW, XP (and 2k)

This should have been XP Pro (and 2k)...

  come with `cygpath -S`/ping.exe and `cygpath -S`/nslookup.exe.

 ??  ...Doesn't do _anything_ on my computer! -smile-
 (Maybe I'd better to a hunt for them as they aren't in my path today.)

Those *are* the complete paths to the files -- just do ls -l path for
each of them.  But if you have XP Home, you may not have them. :-(
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.  -- Dr. Jubal Harshaw

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



RE: seg-vios from gcc program at execv() on Windows XP

2004-10-01 Thread Dave Korn
 -Original Message-
 From: cygwin-owner On Behalf Of Igor Pechtchanski
 Sent: 01 October 2004 15:31

  Almost; right issue, wrong problem. It turned out not that 
 there wasn't a
  terminating NULL but that there was an extra one, one past where it
  should have been! This kind of problem is, apparently, 
 _very_ easy to
  overlook and I guess we just got away with it in the past. -shrug-
 
 Hmm, an extra NULL shouldn't have any effect -- execv stops 
 at the first one, IIRC.  

  Yes, but if you've created an argv[] on the stack to pass to execv, and it has
just the right number of entries, and you go and write an extra NULL into
it  

  IOW, the extra NULL does have an effect... just not on execv!


cheers, 
  DaveK
-- 
Can't think of a witty .sigline today


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



RE: seg-vios from gcc program at execv() on Windows XP

2004-10-01 Thread Igor Pechtchanski
On Fri, 1 Oct 2004, Dave Korn wrote:

  -Original Message-
  From: cygwin-owner On Behalf Of Igor Pechtchanski
  Sent: 01 October 2004 15:31

   Almost; right issue, wrong problem. It turned out not that there
   wasn't a terminating NULL but that there was an extra one, one past
   where it should have been! This kind of problem is, apparently,
   _very_ easy to overlook and I guess we just got away with it in the
   past. -shrug-
 
  Hmm, an extra NULL shouldn't have any effect -- execv stops
  at the first one, IIRC.

   Yes, but if you've created an argv[] on the stack to pass to execv, and it has
 just the right number of entries, and you go and write an extra NULL into
 it

   IOW, the extra NULL does have an effect... just not on execv!

Ah.  Argm.  Ungh.  Ehm.  (a whole list of other sounds, that together mean
thanks for the correction). :-)
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.  -- Dr. Jubal Harshaw

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



seg-vios from gcc program at execv() on Windows XP

2004-09-30 Thread Richard Troy

Hello Cygwiners,

I'm a long-time user of Cygwin - love it, depend on it... and rarely have
a problem, but I really need some help with this one particular problem.
I've already tapped into my other technical resources on this and haven't
gotten anywhere at all. It isn't clear this is a Cygwin problem, but then,
it isn't clear that it isn't, either. ...I really need some insight
here...

A couple of weeks ago some skum-bag stole my laptop and my new one came
with Windows XP Professional. ...I now understand what XP stands for: XP
means eXtremely Painful. Anyway, I use the laptop for sales calls (I'm the
technical person) and it just _has_ to work. I've been having trouble
getting my company's software working on the system and my boss said,
well, this is a good chance for you to make sure our stuff works on XP,
so, have fun! - or words to that effect... But I am _not_ having fun.
-frown-

The problem is that we've got a GCC based program that ends up calling
Java via execv(). It _always_ seg-vios when the GCC program itself
is called from another program (non-interactive) and it sometimes seg-vios
when run from an interactive Cygwin Bash prompt. Significant testing has
shown that the interactive failure seems to be associated with environment
variables. For example, the code uses an environment variable to determine
if it should output verbose statements to std-out (via printf), and if
this is set, the execv() always fails. However, it also fails sometimes
depending on other variables that should have _nothing_ to do with the
program.

Here's an excerpt of the code in the vicinity of the exec:

  strcpy(program,JavaHomeenv);
  strcat(program,/bin/java);
  // make sure that argv0 is fully qualified so that java doesn't
  // default to a local binary
  nargv[0]=program;
  //nargv[0]= java;
  nargv[1]= -classpath;
  nargv[2]= classpathenv;
  nargv[3]= std;
  nargv[4]= ck;
  nargv[5]= rus;
  nargv[6]= host;
  nargv[7]= stc;
  nargv[8]= stt;
  nargv[9]= dk;
  nargv[10]= cl;

  i = execv(program, nargv);

Note that the code is _rock_solid_ on Linux/Unix/Mac OSX, and on all
earlier versions of Windows we've ever tried it on. We've _never_ seen it
seg-vio before.

Also note that I recompiled the executable on the target system. I'm
wondering if there's something about the new installation of Cygwin on XP
that's changed something about how the binary runs...

In case it helps: cygcheck -s says we're running 1.5.10, and gcc is
3.3.1-3. It was a fresh, absolutely complete installation - even the stuff
I never need. (BTW ping and dig utilities would be nice!)

Help!

Thanks everyone,
Richard

-- 
Richard Troy, Chief Scientist
Science Tools Corporation
[EMAIL PROTECTED], 510-567-9957, http://ScienceTools.com/


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: seg-vios from gcc program at execv() on Windows XP

2004-09-30 Thread Igor Pechtchanski
On Thu, 30 Sep 2004, Richard Troy wrote:

 Hello Cygwiners,

I believe the technical term is cygwinners (unless you really mean
cygwhiners? ];-)

 I'm a long-time user of Cygwin - love it, depend on it... and rarely have
 a problem, but I really need some help with this one particular problem.
 I've already tapped into my other technical resources on this and haven't
 gotten anywhere at all. It isn't clear this is a Cygwin problem, but then,
 it isn't clear that it isn't, either. ...I really need some insight
 here...

 A couple of weeks ago some skum-bag stole my laptop and my new one came
 with Windows XP Professional. ...I now understand what XP stands for: XP
 means eXtremely Painful. Anyway, I use the laptop for sales calls (I'm the
 technical person) and it just _has_ to work. I've been having trouble
 getting my company's software working on the system and my boss said,
 well, this is a good chance for you to make sure our stuff works on XP,
 so, have fun! - or words to that effect... But I am _not_ having fun.
 -frown-

 The problem is that we've got a GCC based program that ends up calling
 Java via execv(). It _always_ seg-vios when the GCC program itself
 is called from another program (non-interactive) and it sometimes seg-vios
 when run from an interactive Cygwin Bash prompt. Significant testing has
 shown that the interactive failure seems to be associated with environment
 variables. For example, the code uses an environment variable to determine
 if it should output verbose statements to std-out (via printf), and if
 this is set, the execv() always fails. However, it also fails sometimes
 depending on other variables that should have _nothing_ to do with the
 program.

 Here's an excerpt of the code in the vicinity of the exec:

   strcpy(program,JavaHomeenv);
   strcat(program,/bin/java);
   // make sure that argv0 is fully qualified so that java doesn't
   // default to a local binary
   nargv[0]=program;
   //nargv[0]= java;
   nargv[1]= -classpath;
   nargv[2]= classpathenv;
   nargv[3]= std;
   nargv[4]= ck;
   nargv[5]= rus;
   nargv[6]= host;
   nargv[7]= stc;
   nargv[8]= stt;
   nargv[9]= dk;
   nargv[10]= cl;

   i = execv(program, nargv);

 Note that the code is _rock_solid_ on Linux/Unix/Mac OSX, and on all
 earlier versions of Windows we've ever tried it on. We've _never_ seen it
 seg-vio before.

Please provide a complete (hopefully simple) testcase, along with the
compilation flags, etc.  In particular, it'd be interesting to see how
nargv is allocated, etc.  I suspect you're not placing a NULL at the end
of the argument list, and Cygwin and Linux allocate nargv differently (so
that on Linux, nargv just happens to have zeroed memory after it).

FWIW, I have written a program that invokes java with various arguments
via execv (in almost exactly the same way as above), and it works just
fine on XP Pro.

 Also note that I recompiled the executable on the target system. I'm
 wondering if there's something about the new installation of Cygwin on XP
 that's changed something about how the binary runs...

More likely the memory alloc changes exposed a bug in your code.  If you
can come up with a program that tries invoking Java with constant
arguments and gets a SEGV, please post it.

 In case it helps: cygcheck -s says we're running 1.5.10, and gcc is
 3.3.1-3. It was a fresh, absolutely complete installation - even the stuff
 I never need.

A better way to inform us about your system configuration would be to
*attach* (as an uncompressed text attachment) the output of cygcheck
-svr, as requested in the Cygwin problem reporting guidelines at
http://cygwin.com/problems.html.

 (BTW ping and dig utilities would be nice!)

FWIW, XP (and 2k) come with `cygpath -S`/ping.exe and
`cygpath -S`/nslookup.exe.  There were also some threads on porting ping
to Cygwin -- search the list archives.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.  -- Dr. Jubal Harshaw

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



[OT] Re: seg-vios from gcc program at execv() on Windows XP

2004-09-30 Thread Brian Dessent
Igor Pechtchanski wrote:

  (BTW ping and dig utilities would be nice!)
 
 FWIW, XP (and 2k) come with `cygpath -S`/ping.exe and
 `cygpath -S`/nslookup.exe.  There were also some threads on porting ping
 to Cygwin -- search the list archives.

I know this is heading off topic...

I like to install the win32 version of ISC BIND9, which gives a
unix-like dig / host / nslookup / named / rndc.  (It also allows you to
run your own caching resolver, which you can appreciate if you happen to
have a flakey ISP with poor nameservers.)

It would be nice to have a true Cygwin-ported set of netutils though, no
doubt about it.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: seg-vios from gcc program at execv() on Windows XP

2004-09-30 Thread Richard Troy

On Thu, 30 Sep 2004, Igor Pechtchanski wrote:


  Note that the code is _rock_solid_ on Linux/Unix/Mac OSX, and on all
  earlier versions of Windows we've ever tried it on. We've _never_ seen it
  seg-vio before.

 Please provide a complete (hopefully simple) testcase, along with the
 compilation flags, etc.  In particular, it'd be interesting to see how
 nargv is allocated, etc.  I suspect you're not placing a NULL at the end
 of the argument list, and Cygwin and Linux allocate nargv differently (so
 that on Linux, nargv just happens to have zeroed memory after it).

Almost; right issue, wrong problem. It turned out not that there wasn't a
terminating NULL but that there was an extra one, one past where it
should have been! This kind of problem is, apparently, _very_ easy to
overlook and I guess we just got away with it in the past. -shrug-

I want to thank you for taking the time to reply, Igor. I was awfully
stressed out about it. Even though it wasn't really a Cygwin problem, you
were supportive and I appreciagte it.

  (BTW ping and dig utilities would be nice!)

 FWIW, XP (and 2k) come with `cygpath -S`/ping.exe and
 `cygpath -S`/nslookup.exe.

??  ...Doesn't do _anything_ on my computer! -smile-

(Maybe I'd better to a hunt for them as they aren't in my path today.)

Richard

-- 
Richard Troy, Chief Scientist
Science Tools Corporation
[EMAIL PROTECTED], 510-567-9957, http://ScienceTools.com/


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/