comp.lang.ada
 help / color / mirror / Atom feed
* Exception handler does not catch an exception
@ 2009-06-08  3:19 Rick
  2009-06-08  5:16 ` anon
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Rick @ 2009-06-08  3:19 UTC (permalink / raw)


I am using an exception handler in the mainline of my program:

exception
   when Error : PROGRAM_ERROR =>
      Put_Line (Exception_Message (Error));
      Get_Line (Line, Last);
   when Another_Error : others =>
      Put_Line (Exception_Message (Another_Error));
      Get_Line (Line, Last);
end Phone_Keyboard;

but I still get an error message:

D:\ProgrammingFiles\Widgets\PhoneKeyboard\Phone_Keyboard

Execution terminated by unhandled exception
Exception name: PROGRAM_ERROR
Message: EXCEPTION_ACCESS_VIOLATION
Call stack traceback locations:
0x4483c5 0x7c9032a6 0x7c903278 0x7c90e488 0x407289 0x4017f2 0x401235
0x401286 0x7c817075
[2009-06-08 10:48:19] process exited with status1 (elapsed time:
03.28s)


Why is my exception handler not handling the exception?



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

* Re: Exception handler does not catch an exception
  2009-06-08  3:19 Exception handler does not catch an exception Rick
@ 2009-06-08  5:16 ` anon
  2009-06-08  7:21   ` rickduley
  2009-06-08  7:37 ` Ludovic Brenta
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: anon @ 2009-06-08  5:16 UTC (permalink / raw)


From what you have posted the exception is first trapped, but causes another 
exception with the statement:

     Get_Line (Line, Last);

You might first try commenting this line or changing the line to: 

     Skip_Line ;


  
In <b75654d0-00d5-47cc-97b9-ee29bee6e58e@q2g2000vbr.googlegroups.com>, Rick <rickduley@gmail.com> writes:
>I am using an exception handler in the mainline of my program:
>
>exception
>   when Error : PROGRAM_ERROR =>
>      Put_Line (Exception_Message (Error));
>      Get_Line (Line, Last);
>   when Another_Error : others =>
>      Put_Line (Exception_Message (Another_Error));
>      Get_Line (Line, Last);
>end Phone_Keyboard;
>
>but I still get an error message:
>
>D:\ProgrammingFiles\Widgets\PhoneKeyboard\Phone_Keyboard
>
>Execution terminated by unhandled exception
>Exception name: PROGRAM_ERROR
>Message: EXCEPTION_ACCESS_VIOLATION
>Call stack traceback locations:
>0x4483c5 0x7c9032a6 0x7c903278 0x7c90e488 0x407289 0x4017f2 0x401235
>0x401286 0x7c817075
>[2009-06-08 10:48:19] process exited with status1 (elapsed time:
>03.28s)
>
>
>Why is my exception handler not handling the exception?




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

* Re: Exception handler does not catch an exception
  2009-06-08  5:16 ` anon
@ 2009-06-08  7:21   ` rickduley
  2009-06-08 11:40     ` anon
  0 siblings, 1 reply; 10+ messages in thread
From: rickduley @ 2009-06-08  7:21 UTC (permalink / raw)


On Jun 8, 1:16 pm, a...@anon.org (anon) wrote:
> From what you have posted the exception is first trapped, but causes another
> exception with the statement:
>
>      Get_Line (Line, Last);
>
> You might first try commenting this line or changing the line to:
>
>      Skip_Line ;
>


The Get_Line is simply to hold the message in the command window while
I read the results.
It doesn't work, as you can see from the line

[2009-06-08 10:48:19] process exited with status1 (elapsed time:
03.28s)

in the error message.  The process has exited without waiting for the
Get_Line.  This means it did not get into the exception handler.  If
it had it would have printed the message, not the traceback locations.



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

* Re: Exception handler does not catch an exception
  2009-06-08  3:19 Exception handler does not catch an exception Rick
  2009-06-08  5:16 ` anon
@ 2009-06-08  7:37 ` Ludovic Brenta
  2009-06-09 10:50   ` Stephen Leake
  2009-06-09  2:01 ` rickduley
  2009-06-14 14:12 ` Alex R. Mosteo
  3 siblings, 1 reply; 10+ messages in thread
From: Ludovic Brenta @ 2009-06-08  7:37 UTC (permalink / raw)


On Jun 8, 5:19 am, Rick <rickdu...@gmail.com> wrote:
> I am using an exception handler in the mainline of my program:
>
> exception
>    when Error : PROGRAM_ERROR =>
>       Put_Line (Exception_Message (Error));
>       Get_Line (Line, Last);
>    when Another_Error : others =>
>       Put_Line (Exception_Message (Another_Error));
>       Get_Line (Line, Last);
> end Phone_Keyboard;
>
> but I still get an error message:
>
> D:\ProgrammingFiles\Widgets\PhoneKeyboard\Phone_Keyboard
>
> Execution terminated by unhandled exception
> Exception name: PROGRAM_ERROR
> Message: EXCEPTION_ACCESS_VIOLATION
> Call stack traceback locations:
> 0x4483c5 0x7c9032a6 0x7c903278 0x7c90e488 0x407289 0x4017f2 0x401235
> 0x401286 0x7c817075
> [2009-06-08 10:48:19] process exited with status1 (elapsed time:
> 03.28s)
>
> Why is my exception handler not handling the exception?

I can see three possible reasons but I cannot be sure if you don't
post your entire program.

Possible cause 1: exception during elaboration, i.e. before your main
subprogram starts.
Possible cause 2: exception during elaboration of the main
subprogram's local variables, i.e. before its "begin" keyword.
Possible cause 3: exception in a task other than the environment task.

The stack trace points you to the exact location of the problem.

--
Ludovic Brenta.



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

* Re: Exception handler does not catch an exception
  2009-06-08  7:21   ` rickduley
@ 2009-06-08 11:40     ` anon
  0 siblings, 0 replies; 10+ messages in thread
From: anon @ 2009-06-08 11:40 UTC (permalink / raw)


If you try to read past the end_of_line or end_of_file then "Get_Line" will 
cause the exception.  The "Skip_line" may correct the end_of_line condition, 
unless the end_of_line is follow by an end_of_file condition. The end_of_line 
and end_of_file can be inserted or embeded in the line you are trying to read.

You can trace the error with GDB and the stack dump.

Or to gives us a more clearer picture you can post the complete routine and a 
sample of the line to be read by the routine.

In <c0998767-78da-44da-ae0e-bd6daa6d30a1@o36g2000vbi.googlegroups.com>, rickduley <rickduley@gmail.com> writes:
>On Jun 8, 1:16=A0pm, a...@anon.org (anon) wrote:
>> From what you have posted the exception is first trapped, but causes anot=
>her
>> exception with the statement:
>>
>> =A0 =A0 =A0Get_Line (Line, Last);
>>
>> You might first try commenting this line or changing the line to:
>>
>> =A0 =A0 =A0Skip_Line ;
>>
>
>
>The Get_Line is simply to hold the message in the command window while
>I read the results.
>It doesn't work, as you can see from the line
>
>[2009-06-08 10:48:19] process exited with status1 (elapsed time:
>03.28s)
>
>in the error message.  The process has exited without waiting for the
>Get_Line.  This means it did not get into the exception handler.  If
>it had it would have printed the message, not the traceback locations.




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

* Re: Exception handler does not catch an exception
  2009-06-08  3:19 Exception handler does not catch an exception Rick
  2009-06-08  5:16 ` anon
  2009-06-08  7:37 ` Ludovic Brenta
@ 2009-06-09  2:01 ` rickduley
  2009-06-09  7:26   ` Dmitry A. Kazakov
  2009-06-10 10:06   ` Stephen Leake
  2009-06-14 14:12 ` Alex R. Mosteo
  3 siblings, 2 replies; 10+ messages in thread
From: rickduley @ 2009-06-09  2:01 UTC (permalink / raw)


Thanks to those who replied to my plea.  The issue is resolved.  I am
not too sure what I did that fixed it but I suspect that I was trying
to add something to an unitialised widget in GtkAda.

addr2line obviously does not like GtkAda because the output was
unintelligible.  However, the problem has gone away.

Thanks again - the suggestions gave me a lot of things to look for
next time.

--------------------------------------------
Rick Duley
North Perth,
Western Australia
http://www.freewebs.com/rickduley/
                                     .-_|\
                                    /     \
                              perth *_.-._/
                                         v
aussie :    0409 106 049
o'seas : +61 409 106 049
--------------------------------------------
Committees:
"... dark alley down which ideas are led
                    ... then strangled."
                                   (PepsiCo)



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

* Re: Exception handler does not catch an exception
  2009-06-09  2:01 ` rickduley
@ 2009-06-09  7:26   ` Dmitry A. Kazakov
  2009-06-10 10:06   ` Stephen Leake
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry A. Kazakov @ 2009-06-09  7:26 UTC (permalink / raw)


On Mon, 8 Jun 2009 19:01:53 -0700 (PDT), rickduley wrote:

> addr2line obviously does not like GtkAda because the output was
> unintelligible.

It does not like C. If an exception is propagated through GTK/Glib etc,
which is almost always the case with GtkAda, you almost certainly get the
call stack corrupted.

>  I am
> not too sure what I did that fixed it but I suspect that I was trying
> to add something to an unitialised widget in GtkAda.

When you extend a GTK class, you have to initialize the parent widget
before Initialize_Class_Record. Further, some GTK calls are allowed only
when the widget is so called "realized". There is a countless number of
things one could do wrong in GTK...

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Exception handler does not catch an exception
  2009-06-08  7:37 ` Ludovic Brenta
@ 2009-06-09 10:50   ` Stephen Leake
  0 siblings, 0 replies; 10+ messages in thread
From: Stephen Leake @ 2009-06-09 10:50 UTC (permalink / raw)


Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> The stack trace points you to the exact location of the problem.

use addr2line -e <name of main> <stack trace> to see the stack trace
in symbolic form

-- 
-- Stephe



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

* Re: Exception handler does not catch an exception
  2009-06-09  2:01 ` rickduley
  2009-06-09  7:26   ` Dmitry A. Kazakov
@ 2009-06-10 10:06   ` Stephen Leake
  1 sibling, 0 replies; 10+ messages in thread
From: Stephen Leake @ 2009-06-10 10:06 UTC (permalink / raw)


rickduley <rickduley@gmail.com> writes:

> Thanks to those who replied to my plea.  The issue is resolved.  I am
> not too sure what I did that fixed it but I suspect that I was trying
> to add something to an unitialised widget in GtkAda.

Ok, good.

> addr2line obviously does not like GtkAda because the output was
> unintelligible.  

This may be more due to optimization settings; the output is more
reliable with -O0.

-- 
-- Stephe



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

* Re: Exception handler does not catch an exception
  2009-06-08  3:19 Exception handler does not catch an exception Rick
                   ` (2 preceding siblings ...)
  2009-06-09  2:01 ` rickduley
@ 2009-06-14 14:12 ` Alex R. Mosteo
  3 siblings, 0 replies; 10+ messages in thread
From: Alex R. Mosteo @ 2009-06-14 14:12 UTC (permalink / raw)


Rick wrote:

> I am using an exception handler in the mainline of my program:
> 
> exception
>    when Error : PROGRAM_ERROR =>
>       Put_Line (Exception_Message (Error));
>       Get_Line (Line, Last);
>    when Another_Error : others =>
>       Put_Line (Exception_Message (Another_Error));
>       Get_Line (Line, Last);
> end Phone_Keyboard;
> 
> but I still get an error message:
> 
> D:\ProgrammingFiles\Widgets\PhoneKeyboard\Phone_Keyboard
> 
> Execution terminated by unhandled exception
> Exception name: PROGRAM_ERROR
> Message: EXCEPTION_ACCESS_VIOLATION
> Call stack traceback locations:
> 0x4483c5 0x7c9032a6 0x7c903278 0x7c90e488 0x407289 0x4017f2 0x401235
> 0x401286 0x7c817075
> [2009-06-08 10:48:19] process exited with status1 (elapsed time:
> 03.28s)
> 
> 
> Why is my exception handler not handling the exception?

Besides the reason for this, some exceptions (e.g. Storage_Error after an 
invalid pointer dereference) can't be "handled away", in the sense that 
having a handle for them won't prevent program termination. They appear for 
example when your program is dying from an access violation, and in my 
experience, sometimes the program dies before handling, or shortly after, 
but in any case it is doomed.



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

end of thread, other threads:[~2009-06-14 14:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-08  3:19 Exception handler does not catch an exception Rick
2009-06-08  5:16 ` anon
2009-06-08  7:21   ` rickduley
2009-06-08 11:40     ` anon
2009-06-08  7:37 ` Ludovic Brenta
2009-06-09 10:50   ` Stephen Leake
2009-06-09  2:01 ` rickduley
2009-06-09  7:26   ` Dmitry A. Kazakov
2009-06-10 10:06   ` Stephen Leake
2009-06-14 14:12 ` Alex R. Mosteo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox