My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

Hello,

This is a simple program that I compile as a console application in 
Visual Studio 2005 :

--
#include windows.h
#include stdio.h

LONG WINAPI my_exception_filter (LPEXCEPTION_POINTERS exceptionInfo)
{
printf (*** my_exception_filter ***\n);
return EXCEPTION_EXECUTE_HANDLER;
}


int main(int argc, char *argv[])
{
printf (\n*** SetUnhandledExceptionFilter ***\n);
SetUnhandledExceptionFilter (my_exception_filter);


printf (*** RaiseException ***\n);
RaiseException(EXCEPTION_NONCONTINUABLE_EXCEPTION , 
EXCEPTION_NONCONTINUABLE, 0, NULL);

}
--

If I run this program in standard Windows CMD window, it prints whatever 
it should, and terminates.


If I run this program under CYGWIN, the result depends:
- in standard window (the one that is open by picking Cygwin bash 
shell link in the menu) - the program exits after printing
- if I start rxvt or xterm from the standard window, and then run this 
program in rxvt/xterm window, the program restarts 5 times, each time it 
prints what it should.


Can somebody check my sanity and confirm that this problem is 
reproducible anywhere else?


I'm on Windows XP SP2, all the latest patches, etc.
Cygwin version is 1.5.24 (the latest).

Any help is greatly appreciated.

Thank you,
Alex

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Tue, May 15, 2007 at 11:52:50PM -0700, Alex Shturm wrote:
Hello,

This is a simple program that I compile as a console application in 
Visual Studio 2005 :
--
#include windows.h
#include stdio.h

LONG WINAPI my_exception_filter (LPEXCEPTION_POINTERS exceptionInfo)
{
printf (*** my_exception_filter ***\n);
return EXCEPTION_EXECUTE_HANDLER;
}


int main(int argc, char *argv[])
{
printf (\n*** SetUnhandledExceptionFilter ***\n);
SetUnhandledExceptionFilter (my_exception_filter);


printf (*** RaiseException ***\n);
RaiseException(EXCEPTION_NONCONTINUABLE_EXCEPTION , 
EXCEPTION_NONCONTINUABLE, 0, NULL);
}
--

Cygwin uses the equivalent of SetUnhandledExceptionFilter for its own
purposes.  It can do that because there is no linux version of that
function.

So, if you attempt to use it in a cygwin-aware program, you're in for
problems.  If you need to produce pure windows programs, I'd suggest
http://mingw.org/ .  It doesn't seem like you need Cygwin for the
above.

cgf

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

Christopher,

Cygwin uses the equivalent of SetUnhandledExceptionFilter for its own
purposes.  It can do that because there is no linux version of that
function.

So, if you attempt to use it in a cygwin-aware program, you're in for
problems.  If you need to produce pure windows programs, I'd suggest
http://mingw.org/ .  It doesn't seem like you need Cygwin for the
above.

cgf
  
This small program is just a tiny part of a huge application, which is 
built natively on Windows, and intended to be run without Cygwin by the 
customers.
However we in development use Cygwin extensively, mostly to use the same 
scripts/environment as on Unix platforms (where our application is also 
built).
Hence your suggestion to use mingw is not applicable in our case. Out 
application is not cygwin-aware.


Still something does not look right to me:

(1) Even if cygwin has its own exception handling, how is it possible 
that it interferes with exception handling in my program (which is a 
separate process) ?


(2) Why this issue is not reproducible when cygwin shell is started in a 
regular (cmd?) window, but reproducible only in rxvt/xterm window?


BTW, I've tried running this program under bash, tcsh, and sh, and the 
behavior is the same - that is, the shell is not relevant to this 
problem, only window type is relevant.


It looks like a rxvt/xterm-specific issue.

I wonder if somebody can take a look at it...

Thanks,
Alex

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 11:14:36AM -0700, Alex Shturm wrote:
cgf wrote:
Cygwin uses the equivalent of SetUnhandledExceptionFilter for its own
purposes.  It can do that because there is no linux version of that
function.

So, if you attempt to use it in a cygwin-aware program, you're in for
problems.  If you need to produce pure windows programs, I'd suggest
http://mingw.org/ .  It doesn't seem like you need Cygwin for the
above.
  
This small program is just a tiny part of a huge application, which is 
built natively on Windows, and intended to be run without Cygwin by the 
customers.

If it is going to be run without Cygwin then you shouldn't be using
cygwin's gcc.

However we in development use Cygwin extensively, mostly to use the same 
scripts/environment as on Unix platforms (where our application is also 
built).

You may be a little confused here.  I'm not suggesting that you have to
wipe cygwin from your hard drive to use MinGW.  For the most part,
Cygwin runs standard windows applications, like the MinGW build tools,
just fine.

Hence your suggestion to use mingw is not applicable in our case. Out 
application is not cygwin-aware.

If you are using gcc to build your program then you are building a
cygwin application regardless of whether you use anything from the
cygwin API.  Cygwin is a *dll* it will get loaded automatically when
you start your program and it will do things with exception handling.

Btw, if you build your program with standard cygwin gcc is also GPLed,
which means that you must provide source code for the program to your
customers.

Still something does not look right to me:

(1) Even if cygwin has its own exception handling, how is it possible 
that it interferes with exception handling in my program (which is a 
separate process) ?

see above.

(2) Why this issue is not reproducible when cygwin shell is started in a 
regular (cmd?) window, but reproducible only in rxvt/xterm window?

Dunno but I'm not particularly interested in finding out.  I know for
sure that if you do what you're doing you will have problems.

I wonder if somebody can take a look at it...

It's not likely.  Sorry.  You really should just make your program a
pure windows program.  It will still run under rxvt, bash, etc.  but it
isn't likely that it will manifest this problem and you won't have to
provide your source code to your customers under the GPL.

You can also use the -mno-cygwin option to gcc which will avoid using
the cygwin environment when compiling/linking.  I avoided mentioning
this before because it is a constant source of confusion with people
because it doesn't always work 100% correctly and people somehow think
that it is a way to avoid the GPL but still have cygwin functionality.
It may work in your case but MinGW is cleaner.

cgf

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

Christopher,

I agree there is a misunderstanding here.
Please see my original post - there I clearly say that I build this 
program in Visual Studio 2005, and not using gcc.


I only have problems *running* it under cygwin.

Thanks,
Alex

Christopher Faylor wrote:

On Wed, May 16, 2007 at 11:14:36AM -0700, Alex Shturm wrote:
  

cgf wrote:


Cygwin uses the equivalent of SetUnhandledExceptionFilter for its own
purposes.  It can do that because there is no linux version of that
function.

So, if you attempt to use it in a cygwin-aware program, you're in for
problems.  If you need to produce pure windows programs, I'd suggest
http://mingw.org/ .  It doesn't seem like you need Cygwin for the
above.
  
 
This small program is just a tiny part of a huge application, which is 
built natively on Windows, and intended to be run without Cygwin by the 
customers.



If it is going to be run without Cygwin then you shouldn't be using
cygwin's gcc.

  
However we in development use Cygwin extensively, mostly to use the same 
scripts/environment as on Unix platforms (where our application is also 
built).



You may be a little confused here.  I'm not suggesting that you have to
wipe cygwin from your hard drive to use MinGW.  For the most part,
Cygwin runs standard windows applications, like the MinGW build tools,
just fine.

  
Hence your suggestion to use mingw is not applicable in our case. Out 
application is not cygwin-aware.



If you are using gcc to build your program then you are building a
cygwin application regardless of whether you use anything from the
cygwin API.  Cygwin is a *dll* it will get loaded automatically when
you start your program and it will do things with exception handling.

Btw, if you build your program with standard cygwin gcc is also GPLed,
which means that you must provide source code for the program to your
customers.

  

Still something does not look right to me:

(1) Even if cygwin has its own exception handling, how is it possible 
that it interferes with exception handling in my program (which is a 
separate process) ?



see above.

  
(2) Why this issue is not reproducible when cygwin shell is started in a 
regular (cmd?) window, but reproducible only in rxvt/xterm window?



Dunno but I'm not particularly interested in finding out.  I know for
sure that if you do what you're doing you will have problems.

  

I wonder if somebody can take a look at it...



It's not likely.  Sorry.  You really should just make your program a
pure windows program.  It will still run under rxvt, bash, etc.  but it
isn't likely that it will manifest this problem and you won't have to
provide your source code to your customers under the GPL.

You can also use the -mno-cygwin option to gcc which will avoid using
the cygwin environment when compiling/linking.  I avoided mentioning
this before because it is a constant source of confusion with people
because it doesn't always work 100% correctly and people somehow think
that it is a way to avoid the GPL but still have cygwin functionality.
It may work in your case but MinGW is cleaner.

cgf

  


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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 11:57:30AM -0700, Alex Shturm wrote:
Christopher,

I agree there is a misunderstanding here.
Please see my original post - there I clearly say that I build this 
program in Visual Studio 2005, and not using gcc.

SORRY.  I completely misread the run this program under CYGWIN as
meaning that you recompiled using Cygwin's gcc even though that clearly
is not what you meant.

I don't have Visual Studio available to test this so I don't know if
I'll be able to be of much help here.  I'll try the test case under
mingw, however, as soon as I get to a computer where I can do that.

Apologies again for wasting your time with my misreading of your
message.

cgf

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 03:13:07PM -0400, Christopher Faylor wrote:
On Wed, May 16, 2007 at 11:57:30AM -0700, Alex Shturm wrote:
Christopher,

I agree there is a misunderstanding here.
Please see my original post - there I clearly say that I build this 
program in Visual Studio 2005, and not using gcc.

SORRY.  I completely misread the run this program under CYGWIN as
meaning that you recompiled using Cygwin's gcc even though that clearly
is not what you meant.

I don't have Visual Studio available to test this so I don't know if
I'll be able to be of much help here.  I'll try the test case under
mingw, however, as soon as I get to a computer where I can do that.

Apologies again for wasting your time with my misreading of your
message.

Actually, nevermind.  I know what the problem is.  Cygwin is
interpreting the exit value from your program as being indicative of a
hard failure and trying to rerun it as a result.  If you explicitly exit
with a value less than 65535 it should work better.

cgf

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

Wow.
Is it a documented behavior?
What is the reason for cygwin to believe that the program needs to be 
re-run?


I'm not sure how I can control the exit value if the actual exit is 
performed by exception handler...


Thanks,
Alex

Christopher Faylor wrote:

Actually, nevermind.  I know what the problem is.  Cygwin is
interpreting the exit value from your program as being indicative of a
hard failure and trying to rerun it as a result.  If you explicitly exit
with a value less than 65535 it should work better.

cgf

  


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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 12:31:58PM -0700, Alex Shturm wrote:
Wow.
Is it a documented behavior?

http://cygwin.com/cygwin-ug-net/using-cygwinenv.html

See the proc_retry entry.  It neglects to mention that the default is
10.

You might be able to set CYGWIN=proc_retry:1 but it's possible that
Cygwin might still think your program was dying and report that.

cgf

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

It did not help... :(
The program still restarts 5 times...

Christopher Faylor wrote:

On Wed, May 16, 2007 at 12:31:58PM -0700, Alex Shturm wrote:
  

Wow.
Is it a documented behavior?



http://cygwin.com/cygwin-ug-net/using-cygwinenv.html

See the proc_retry entry.  It neglects to mention that the default is
10.

You might be able to set CYGWIN=proc_retry:1 but it's possible that
Cygwin might still think your program was dying and report that.

cgf

  


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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 01:26:07PM -0700, Alex Shturm wrote:
It did not help... :(
The program still restarts 5 times...

You did set it before running any cygwin shell, right?

cgf

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



Re: glXChooseVisual does not handle GLX_RGBA correctly

2007-05-16 Thread Larry Hall (Cygwin X)
Geoff Levner wrote:
 Larry Hall (Cygwin X) wrote:
 Geoff Levner wrote:
 
 I have an OpenGL-based application executing on a Sun, but displaying
 on a PC running Windows XP and an X server. The app requires a
 TrueColor visual, so when it calls glXChooseVisual, it passes
 GLX_RGBA in the attribute list. This works fine with another X server
 (Exceed), but when using Cygwin/X, glXChooseVisual fails to return a
 visual.
 
 Running xdpyinfo would seem to indicate that the server has *only* 
 TrueColor visuals (see the output below). And in fact if I remove 
 GLX_RGBA from the attribute list, glXChooseVisual does return one of 
 those visuals. If I ask for information about the visual with 
 glXGetConfig, it responds that color buffers store color indices 
 (GLX_RGBA is false), yet the application works correctly.
 
 Anybody have a clue what is going on here?
 
 
 
 Looks to me like you're app is looking for 32 bits while Cygwin-X is 
 only providing 24 bits.  Unless you know you absolutely need 
 transparency, I think you'll find everything works fine with the
 visuals you can get. Just ask for GLX_RGB instead.
 
 
 That sounds reasonable, but GLX_RGB is not defined, and I can't find any 
 reference to it in the GLX 1.4 specifications. According to the 
 documentation, GLX_RGBA just means you want TrueColor or DirectColor 
 visuals; it says nothing about alpha. And we do not ask for any alpha 
 bits...


Yup, you're right.  I was thinking of something else.

Perhaps it's just your combination of attributes.  You might check that.
The combination below has worked for me before, albeit from a Linux
machine to Cygwin/X:

int visual_attributes[] =
{
GLX_DOUBLEBUFFER,
GLX_RGBA,
GLX_RED_SIZE,  1,
GLX_GREEN_SIZE,1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE,1,
GLX_STENCIL_SIZE,  1,
GLX_ACCUM_RED_SIZE,1,
GLX_ACCUM_GREEN_SIZE,  1,
GLX_ACCUM_BLUE_SIZE,   1,
None
};




-- 
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 893-9889 - FAX
Holliston, MA 01746

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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Alex Shturm

Christopher,

The description of proc_retry:n did not mention this requirement.

Anyway, after I defined my CYGWIN variable in 
My Computer  Properties  Advanced  Environment Variables, 
everything worked fine!


Thanks a lot for your help!

Alex


It did not help... :(
The program still restarts 5 times...

You did set it before running any cygwin shell, right?

cgf


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



Re: My program restarts six times under Cygwin when run under rxvt/xterm

2007-05-16 Thread Christopher Faylor
On Wed, May 16, 2007 at 04:15:54PM -0700, Alex Shturm wrote:
The description of proc_retry:n did not mention this requirement.

It is a general requirement for the CYGWIN environment variable.

Anyway, after I defined my CYGWIN variable in 
My Computer  Properties  Advanced  Environment Variables, 
everything worked fine!

Glad (and surprised) it worked.

cgf

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