public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Cygwin shell eats Windows exceptions?
@ 2016-10-13 15:24 Bill Smith
  2016-10-13 16:57 ` Brian Inglis
  2016-10-13 22:55 ` Peter Rosin
  0 siblings, 2 replies; 13+ messages in thread
From: Bill Smith @ 2016-10-13 15:24 UTC (permalink / raw)
  To: cygwin

Hi,
I'm trying to run my Windows C++ application which has a call to DebugBreak() to bring up the popup asking if you want to debug this application or terminate it.  If I run the program within Cygwin, the program just exits. 

If I run the application from a Windows command prompt, I get the Windows popup that I'm expecting.  It seems that the Cygwin shell is eating exceptions (sigsegv or similar signals?).  Is there a way for me to disable this behavior?  

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 15:24 Cygwin shell eats Windows exceptions? Bill Smith
@ 2016-10-13 16:57 ` Brian Inglis
  2016-10-13 18:19   ` Bill Smith
  2016-10-13 22:55 ` Peter Rosin
  1 sibling, 1 reply; 13+ messages in thread
From: Brian Inglis @ 2016-10-13 16:57 UTC (permalink / raw)
  To: cygwin

On 2016-10-13 08:35, Bill Smith wrote:
> I'm trying to run my Windows C++ application which has a call to
> DebugBreak() to bring up the popup asking if you want to debug this
> application or terminate it. If I run the program within Cygwin, the
> program just exits.
> If I run the application from a Windows command prompt, I get the
> Windows popup that I'm expecting. It seems that the Cygwin shell is
> eating exceptions (sigsegv or similar signals?). Is there a way for
> me to disable this behavior?

Not giving us much info to go on here - is this a Cygwin, curses,
Cygwin/X, or Windows native app, and what kind of popup is used?
If a Windows native app, is it a console app, or do you run it with
cygstart from Cygwin?
If a Cygwin or X app, have you tried running strace, gdb (or a GUI FE)
on it?
If the latter, please post or attach the results, and attach the
output from cygcheck -svr in a reply.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Cygwin shell eats Windows exceptions?
  2016-10-13 16:57 ` Brian Inglis
@ 2016-10-13 18:19   ` Bill Smith
  2016-10-13 19:00     ` cyg Simple
  2016-10-13 22:55     ` Brian Inglis
  0 siblings, 2 replies; 13+ messages in thread
From: Bill Smith @ 2016-10-13 18:19 UTC (permalink / raw)
  To: Brian.Inglis, cygwin

[-- Attachment #1: Type: text/plain, Size: 2335 bytes --]


> On 2016-10-13 08:35, Bill Smith wrote:
> > I'm trying to run my Windows C++ application which has a call to
> > DebugBreak() to bring up the popup asking if you want to debug this
> > application or terminate it. If I run the program within Cygwin, the
> > program just exits.
> > If I run the application from a Windows command prompt, I get the
> > Windows popup that I'm expecting. It seems that the Cygwin shell is
> > eating exceptions (sigsegv or similar signals?). Is there a way for me
> > to disable this behavior?
> 
> Not giving us much info to go on here - is this a Cygwin, curses, Cygwin/X, or
> Windows native app, and what kind of popup is used?
> If a Windows native app, is it a console app, or do you run it with cygstart
> from Cygwin?
> If a Cygwin or X app, have you tried running strace, gdb (or a GUI FE) on it?
> If the latter, please post or attach the results, and attach the output from
> cygcheck -svr in a reply.
[Bill Smith] 
Sorry for the lack of info.  This is a Windows native console application.  Here's the source code:

#include <windows.h>

int main()
{
  DebugBreak();
}

Compiled it with Visual Studio 2010:

cl debug.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

debug.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:debug.exe
debug.obj

When you run the application from a Windows command prompt, you get a popup similar to:
http://imgur.com/a/VCgeW

It says "debug.exe has stopped working" and it gives you the option of closing the program, checking online for a solution, or to debug the program.

From a Cygwin shell, nothing happens.

Another example is to do an access violation (segv) with a program like this:


int main() {
 int* f = 0;

  *f = 1234; 
}

In Cygwin, It'll say "Segmentation Fault" and fail.  In Windows command prompt, I get the same popup with the other program which gives me the option to bring up the debugger.

Our product is built using the Visual Studio compiler and we do the build & test from within a Cygwin shell (c:\cygwin\bin\sh.exe).

I attached the cygcheck -svr output to this email.


Thanks,
--Bill




[-- Attachment #2: cygcheck_svr.txt.gz --]
[-- Type: application/x-gzip, Size: 19313 bytes --]

[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 18:19   ` Bill Smith
@ 2016-10-13 19:00     ` cyg Simple
  2016-10-13 20:29       ` Bill Smith
  2016-10-13 22:55     ` Brian Inglis
  1 sibling, 1 reply; 13+ messages in thread
From: cyg Simple @ 2016-10-13 19:00 UTC (permalink / raw)
  To: cygwin

On 10/13/2016 1:56 PM, Bill Smith wrote:
> Sorry for the lack of info.  This is a Windows native console application.  Here's the source code:
> 
> #include <windows.h>
> 

A "console application" doesn't require windows.h but this isn't the issue.

> int main()
> {
>   DebugBreak();
> }
> 
> Compiled it with Visual Studio 2010:
> 
> cl debug.cpp
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> debug.cpp
> Microsoft (R) Incremental Linker Version 10.00.30319.01
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> /out:debug.exe
> debug.obj
> 
> When you run the application from a Windows command prompt, you get a popup similar to:
> http://imgur.com/a/VCgeW
> 
> It says "debug.exe has stopped working" and it gives you the option of closing the program, checking online for a solution, or to debug the program.
> 
> From a Cygwin shell, nothing happens.
> 
> Another example is to do an access violation (segv) with a program like this:
> 
> 
> int main() {
>  int* f = 0;
> 
>   *f = 1234; 
> }
> 
> In Cygwin, It'll say "Segmentation Fault" and fail.  In Windows command prompt, I get the same popup with the other program which gives me the option to bring up the debugger.
> 
> Our product is built using the Visual Studio compiler and we do the build & test from within a Cygwin shell (c:\cygwin\bin\sh.exe).
> 
> I attached the cygcheck -svr output to this email.

The Windows cmd console and the Cygwin console behave differently to the
exception.  Not a bug, just not what you wanted.

What if you 'cmd.exe /c foo.exe' from the Cygwin shell?  Will the
Dialogue popup box occur?  If so you can provide a sh script foo to
execute the foo.exe file.

-- 
cyg Simple

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Cygwin shell eats Windows exceptions?
  2016-10-13 19:00     ` cyg Simple
@ 2016-10-13 20:29       ` Bill Smith
  2016-10-13 22:52         ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 13+ messages in thread
From: Bill Smith @ 2016-10-13 20:29 UTC (permalink / raw)
  To: cyg Simple, cygwin



> > Sorry for the lack of info.  This is a Windows native console application.
> Here's the source code:
> >
> > #include <windows.h>
> >
> A "console application" doesn't require windows.h but this isn't the issue.
[Bill Smith] 
Not sure that I understand.  Is your point that because it includes Windows.h, it's a GUI application?
I was just following the docs here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms679297%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396



> The Windows cmd console and the Cygwin console behave differently to the
> exception.  Not a bug, just not what you wanted.
[Bill Smith] 
Ok, understood.

 
> What if you 'cmd.exe /c foo.exe' from the Cygwin shell?  Will the Dialogue
> popup box occur?  If so you can provide a sh script foo to execute the
> foo.exe file.
[Bill Smith] 
Thanks for the suggestion but that doesn't work.  If I try to open a command prompt from a Cygwin shell (just type in "cmd"), I get the same behavior where I don't see the popup.  If I run "cygstart cmd.exe", then running the program from the command prompt will generate the popup.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 20:29       ` Bill Smith
@ 2016-10-13 22:52         ` Larry Hall (Cygwin)
  2016-10-14 12:34           ` Herbert Stocker
  0 siblings, 1 reply; 13+ messages in thread
From: Larry Hall (Cygwin) @ 2016-10-13 22:52 UTC (permalink / raw)
  To: cygwin

On 10/13/2016 03:00 PM, Bill Smith wrote:

<snip>

>> What if you 'cmd.exe /c foo.exe' from the Cygwin shell?  Will the Dialogue
>> popup box occur?  If so you can provide a sh script foo to execute the
>> foo.exe file.
> [Bill Smith]
> Thanks for the suggestion but that doesn't work. If I try to open a
> command prompt from a Cygwin shell (just type in "cmd"), I get the same
> behavior where I don't see the popup. If I run "cygstart cmd.exe", then
> running the program from the command prompt will generate the popup.

I believe the heart of your question is whether command-line utilities run
under a Cygwin shell react to a terminal exception the same way as when run
outside the shell.  The answer, as you've found, is no, they don't.  This
is by design and there isn't a "switch" to flip to get around it.  The
point is that on Linux/Unix platforms, command-line utilities do not pop up
windows, or any other kind of UI, which seek user input.  Doing so can
cause scripted processes to appear to "hang" and clutter the desktop.
There was a time, long ago, where Cygwin command line utilities would do
exactly that and the behavior was changed to return the error code and move
on, just as would happen under Linux/Unix.

Hope that helps,

-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 18:19   ` Bill Smith
  2016-10-13 19:00     ` cyg Simple
@ 2016-10-13 22:55     ` Brian Inglis
  2016-10-14 17:46       ` Bill Smith
  1 sibling, 1 reply; 13+ messages in thread
From: Brian Inglis @ 2016-10-13 22:55 UTC (permalink / raw)
  To: cygwin

On 2016-10-13 11:56, Bill Smith wrote:
>> On 2016-10-13 08:35, Bill Smith wrote:
>>> I'm trying to run my Windows C++ application which has a call to
>>> DebugBreak() to bring up the popup asking if you want to debug this
>>> application or terminate it. If I run the program within Cygwin, the
>>> program just exits.
>>> If I run the application from a Windows command prompt, I get the
>>> Windows popup that I'm expecting. It seems that the Cygwin shell is
>>> eating exceptions (sigsegv or similar signals?). Is there a way for me
>>> to disable this behavior?
>>
>> Not giving us much info to go on here - is this a Cygwin, curses, Cygwin/X, or
>> Windows native app, and what kind of popup is used?
>> If a Windows native app, is it a console app, or do you run it with cygstart
>> from Cygwin?
>> If a Cygwin or X app, have you tried running strace, gdb (or a GUI FE) on it?
>> If the latter, please post or attach the results, and attach the output from
>> cygcheck -svr in a reply.
> [Bill Smith]
> Sorry for the lack of info.  This is a Windows native console application.  Here's the source code:
> #include <windows.h>
> int main()
> {
>   DebugBreak();
> }
> Compiled it with Visual Studio 2010:
> cl debug.cpp
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
> Copyright (C) Microsoft Corporation.  All rights reserved.
> debug.cpp
> Microsoft (R) Incremental Linker Version 10.00.30319.01
> Copyright (C) Microsoft Corporation.  All rights reserved.
> /out:debug.exe
> debug.obj
> When you run the application from a Windows command prompt, you get a popup similar to:
> http://imgur.com/a/VCgeW
> It says "debug.exe has stopped working" and it gives you the option of closing the program, checking online for a solution, or to debug the program.
> From a Cygwin shell, nothing happens.
> Another example is to do an access violation (segv) with a program like this:
> int main() {
>  int* f = 0;
>   *f = 1234;
> }
> In Cygwin, It'll say "Segmentation Fault" and fail.  In Windows command prompt, I get the same popup with the other program which gives me the option to bring up the debugger.
> Our product is built using the Visual Studio compiler and we do the build & test from within a Cygwin shell (c:\cygwin\bin\sh.exe).
> I attached the cygcheck -svr output to this email.

As it pops up a Windows msgbox, and the process is being run under a pty (pseudo-tty) without any window available, that will just fail.
Why not just trap and report any exceptions console style and return an error?

If you need to do interactive debugging, run it under cmd or with cygstart.
If you need the best of both worlds, you can translate your scripts from bash to cmd and have the option.

-- 
-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 15:24 Cygwin shell eats Windows exceptions? Bill Smith
  2016-10-13 16:57 ` Brian Inglis
@ 2016-10-13 22:55 ` Peter Rosin
  2016-10-14 10:52   ` Peter Rosin
  1 sibling, 1 reply; 13+ messages in thread
From: Peter Rosin @ 2016-10-13 22:55 UTC (permalink / raw)
  To: cygwin

On 2016-10-13 16:35, Bill Smith wrote:
> Hi,
> I'm trying to run my Windows C++ application which has a call to DebugBreak() to bring up the popup asking if you want to debug this application or terminate it.  If I run the program within Cygwin, the program just exits. 
> 
> If I run the application from a Windows command prompt, I get the Windows popup that I'm expecting.  It seems that the Cygwin shell is eating exceptions (sigsegv or similar signals?).  Is there a way for me to disable this behavior?  

I believe you want the reverse of this program:

https://github.com/msysgit/msys/blob/master/winsup/utils/error-mode.c

error-mode can make the popups go away (getting cygwin behavior
on msys), but it should be possible to modify it to make the
popup appear instead. I think...

Cheers,
Peter


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 22:55 ` Peter Rosin
@ 2016-10-14 10:52   ` Peter Rosin
  0 siblings, 0 replies; 13+ messages in thread
From: Peter Rosin @ 2016-10-14 10:52 UTC (permalink / raw)
  To: cygwin



On 2016-10-14 00:52, Peter Rosin wrote:
> On 2016-10-13 16:35, Bill Smith wrote:
>> Hi,
>> I'm trying to run my Windows C++ application which has a call to DebugBreak() to bring up the popup asking if you want to debug this application or terminate it.  If I run the program within Cygwin, the program just exits. 
>>
>> If I run the application from a Windows command prompt, I get the Windows popup that I'm expecting.  It seems that the Cygwin shell is eating exceptions (sigsegv or similar signals?).  Is there a way for me to disable this behavior?  
> 
> I believe you want the reverse of this program:
> 
> https://github.com/msysgit/msys/blob/master/winsup/utils/error-mode.c
> 
> error-mode can make the popups go away (getting cygwin behavior
> on msys), but it should be possible to modify it to make the
> popup appear instead. I think...

feeep, should have read my old code before I posted. The program
should fit the bill. My memory is apparently bad but short.

Sorry for the noise.

Cheers,
Peter

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-13 22:52         ` Larry Hall (Cygwin)
@ 2016-10-14 12:34           ` Herbert Stocker
  0 siblings, 0 replies; 13+ messages in thread
From: Herbert Stocker @ 2016-10-14 12:34 UTC (permalink / raw)
  To: cygwin

On 10/13/2016 11:17 PM, Larry Hall (Cygwin) wrote:
 > The point is that on Linux/Unix platforms, command-line utilities do 
not pop up
 > windows, or any other kind of UI, which seek user input.  Doing so can
 > cause scripted processes to appear to "hang" and clutter the desktop.

Not so anymore. Just the other day sshfs popped up a password dialog on
my kubuntu becasue it had to reconnect. (i did not start it in fore-
ground mode, so sshfs was running in background mode).

And i have seen ssh to ask for the password on OS X via GUI, it was
one of these things that roll down from the top of the window.

best regards,

Herbert





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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Cygwin shell eats Windows exceptions?
  2016-10-13 22:55     ` Brian Inglis
@ 2016-10-14 17:46       ` Bill Smith
  2016-10-18 18:22         ` Wilfried
  0 siblings, 1 reply; 13+ messages in thread
From: Bill Smith @ 2016-10-14 17:46 UTC (permalink / raw)
  To: Brian.Inglis, cygwin


Thanks for all of the responses from everyone. 

> If you need to do interactive debugging, run it under cmd or with cygstart.

[Bill Smith] it seems that an ok workaround is for me to use cygstart to start a command prompt within a Cygwin shell and then in the command prompt, run the program which calls DebugBreak and cause the popup to appear.  The reason for needing to run within Cygwin is because we have a complex shell script that sets the user environment to run the application.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-14 17:46       ` Bill Smith
@ 2016-10-18 18:22         ` Wilfried
  2016-10-18 19:46           ` cyg Simple
  0 siblings, 1 reply; 13+ messages in thread
From: Wilfried @ 2016-10-18 18:22 UTC (permalink / raw)
  To: cygwin

Bill Smith wrote:

> 
> Thanks for all of the responses from everyone. 
> 
> > If you need to do interactive debugging, run it under cmd or with cygstart.
> 
> [Bill Smith] it seems that an ok workaround is for me to use cygstart to start a command prompt within a Cygwin shell and then in the command prompt, run the program which calls DebugBreak and cause the popup to appear.  The reason for needing to run within Cygwin is because we have a complex shell script that sets the user environment to run the application.

OK, if that is the only reason for using cygwin, I can recommend another
way to run a complex shell script in windows.
There is a native windows port of the bash shell in
http://win-bash.sourceforge.net/

If you need more unix command line utilities, look in
https://sourceforge.net/projects/gnuwin32/

HTH, Wilfried
-- 
Wilfried Hennings


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Cygwin shell eats Windows exceptions?
  2016-10-18 18:22         ` Wilfried
@ 2016-10-18 19:46           ` cyg Simple
  0 siblings, 0 replies; 13+ messages in thread
From: cyg Simple @ 2016-10-18 19:46 UTC (permalink / raw)
  To: cygwin

On 10/18/2016 2:03 PM, Wilfried wrote:
> Bill Smith wrote:
> 
>>
>> Thanks for all of the responses from everyone. 
>>
>>> If you need to do interactive debugging, run it under cmd or with cygstart.
>>
>> [Bill Smith] it seems that an ok workaround is for me to use cygstart to start a command prompt within a Cygwin shell and then in the command prompt, run the program which calls DebugBreak and cause the popup to appear.  The reason for needing to run within Cygwin is because we have a complex shell script that sets the user environment to run the application.
> 
> OK, if that is the only reason for using cygwin, I can recommend another
> way to run a complex shell script in windows.
> There is a native windows port of the bash shell in
> http://win-bash.sourceforge.net/
> 
> If you need more unix command line utilities, look in
> https://sourceforge.net/projects/gnuwin32/
> 

Wilfried I think you miss the point of Bill's need and these items you
point to are a bit old as in maintenance appears lacking.  Last file
date for win-bash was 2011 and for gnuwin32 was 2010.

Bill needed to instruct others using Cygwin how to operate with a native
application.  There is no dependence on bash or other scripting language
on Bill's behalf.

-- 
cyg Simple

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-18 18:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-13 15:24 Cygwin shell eats Windows exceptions? Bill Smith
2016-10-13 16:57 ` Brian Inglis
2016-10-13 18:19   ` Bill Smith
2016-10-13 19:00     ` cyg Simple
2016-10-13 20:29       ` Bill Smith
2016-10-13 22:52         ` Larry Hall (Cygwin)
2016-10-14 12:34           ` Herbert Stocker
2016-10-13 22:55     ` Brian Inglis
2016-10-14 17:46       ` Bill Smith
2016-10-18 18:22         ` Wilfried
2016-10-18 19:46           ` cyg Simple
2016-10-13 22:55 ` Peter Rosin
2016-10-14 10:52   ` Peter Rosin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).