comp.lang.ada
 help / color / mirror / Atom feed
* not handled exceptions
@ 2002-03-22 17:40 Michal Nowikowski
  2002-03-23  0:42 ` Greg Bek
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Michal Nowikowski @ 2002-03-22 17:40 UTC (permalink / raw)


Hello

I've got problem with exceptions. It is my code:

declare
  D : Integer_Array_Access;
begin
  -- D is not allocated, so such call should raise 
  -- Constraint_Error exception:
  D(3) := 5;
end;

but program does not throw exception instead it hangs.
When I do:

begin
  D(3) := 5;
exception
  Constraint_Error =>
     put_line("exception raised");
end;

the exception is raised and message is seen - program
continue execution.

I use Gnat 3.14 on Linux box. Have You any idea how to
solve this problem?

Best regards
Godfryd

-- 
|  Michal Nowikowski <godfryd@zamek.gda.pl>
|  BOFH excuse #360: Your parity check is overdrawn and you're out
|  of cache.



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

* Re: not handled exceptions
  2002-03-22 17:40 not handled exceptions Michal Nowikowski
@ 2002-03-23  0:42 ` Greg Bek
  2002-03-23  7:09 ` Wilhelm Spickermann
  2002-03-23 11:52 ` Robert Dewar
  2 siblings, 0 replies; 12+ messages in thread
From: Greg Bek @ 2002-03-23  0:42 UTC (permalink / raw)


Your code is working properly.

In the first example there is no exception handler in the declarative region
where
the array is declared and the exception raised.

As for why it is hanging, the exception is being raised, there is no handler
at local
scope so the exception is propagating outwards looking for a handler.  I'm
guessing
it is reaching the outermost scope of your program and then it is up to the
runtime
system to properly deal with the situation.  Not sure why GNAT hangs.

Greg Bek


"Michal Nowikowski" <godfryd@zamek.gda.pl> wrote in message
news:pan.2002.03.22.18.40.05.457489.4682@zamek.gda.pl...
> Hello
>
> I've got problem with exceptions. It is my code:
>
> declare
>   D : Integer_Array_Access;
> begin
>   -- D is not allocated, so such call should raise
>   -- Constraint_Error exception:
>   D(3) := 5;
> end;
>
> but program does not throw exception instead it hangs.
> When I do:
>
> begin
>   D(3) := 5;
> exception
>   Constraint_Error =>
>      put_line("exception raised");
> end;
>
> the exception is raised and message is seen - program
> continue execution.
>
> I use Gnat 3.14 on Linux box. Have You any idea how to
> solve this problem?
>
> Best regards
> Godfryd
>
> --
> |  Michal Nowikowski <godfryd@zamek.gda.pl>
> |  BOFH excuse #360: Your parity check is overdrawn and you're out
> |  of cache.





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

* Re: not handled exceptions
  2002-03-22 17:40 not handled exceptions Michal Nowikowski
  2002-03-23  0:42 ` Greg Bek
@ 2002-03-23  7:09 ` Wilhelm Spickermann
  2002-03-23  9:36   ` Ingo Marks
  2002-03-23 13:40   ` Michal Nowikowski
  2002-03-23 11:52 ` Robert Dewar
  2 siblings, 2 replies; 12+ messages in thread
From: Wilhelm Spickermann @ 2002-03-23  7:09 UTC (permalink / raw)


Michal Nowikowski <godfryd@zamek.gda.pl> wrote in message news:<pan.2002.03.22.18.40.05.457489.4682@zamek.gda.pl>...
> 
> declare
>   D : Integer_Array_Access;
> begin
>   -- D is not allocated, so such call should raise 
>   -- Constraint_Error exception:
>   D(3) := 5;
> end;
> 
> but program does not throw exception instead it hangs.
...
> I use Gnat 3.14 on Linux box. Have You any idea how to
> solve this problem?

Hi,

that may an installation problem. Your Linux box comes with a gcc and
GNAT comes with a different gcc and both are needed and may not mix
up. The people from gnuada.org have done a great job to close all the
holes where mixups may happen. Gnat 3.13p installed from the RPMs
available at www.gnuada.org doesn't have the problem you have
described and the 3.14p RPMs are announced for about mid April.

Wilhelm



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

* Re: not handled exceptions
  2002-03-23  7:09 ` Wilhelm Spickermann
@ 2002-03-23  9:36   ` Ingo Marks
  2002-03-23 13:40   ` Michal Nowikowski
  1 sibling, 0 replies; 12+ messages in thread
From: Ingo Marks @ 2002-03-23  9:36 UTC (permalink / raw)


Wilhelm Spickermann wrote:

> Michal Nowikowski <godfryd@zamek.gda.pl> wrote in message
>> ...
>> but program does not throw exception instead it hangs.
> ...
>> I use Gnat 3.14 on Linux box. Have You any idea how to
>> solve this problem?
> 
> Hi,
> 
> that may an installation problem. Your Linux box comes with a gcc and
> GNAT comes with a different gcc and both are needed and may not mix
> up. The people from gnuada.org have done a great job to close all the
> holes where mixups may happen. Gnat 3.13p installed from the RPMs
> available at www.gnuada.org doesn't have the problem you have
> described and the 3.14p RPMs are announced for about mid April.
> 
> Wilhelm

On SuSE 7.3 the default C/C++ compiler is named gcc and the GNAT compiler 
is named gnatgcc. Maybe it's the same on your system, so that you must use 
gnatgcc instead of gcc. gnatmake should call the right compiler anyway.

Ingo




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

* Re: not handled exceptions
  2002-03-22 17:40 not handled exceptions Michal Nowikowski
  2002-03-23  0:42 ` Greg Bek
  2002-03-23  7:09 ` Wilhelm Spickermann
@ 2002-03-23 11:52 ` Robert Dewar
  2002-03-23 13:39   ` Michal Nowikowski
  2 siblings, 1 reply; 12+ messages in thread
From: Robert Dewar @ 2002-03-23 11:52 UTC (permalink / raw)


Michal Nowikowski <godfryd@zamek.gda.pl> wrote in message news:<pan.2002.03.22.18.40.05.457489.4682@zamek.gda.pl>...
> Hello
> 
> I've got problem with exceptions. It is my code:

Always, always post an ENTIRE program when you ask for
help. Do not assume you know how to select the relevant
section. For the code you posted, the behavior you
described is quite reasonable, depending on what else
is there in your program.

If you post fragments, then people start guessing what
the rest of the program might be, and you get a bunch
of replies that is even more unreliable than usual!



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

* Re: not handled exceptions
  2002-03-23 11:52 ` Robert Dewar
@ 2002-03-23 13:39   ` Michal Nowikowski
  2002-03-23 15:13     ` Steve Doiel
  0 siblings, 1 reply; 12+ messages in thread
From: Michal Nowikowski @ 2002-03-23 13:39 UTC (permalink / raw)


On Sat, 23 Mar 2002 12:52:18 +0100, Robert Dewar wrote:

>> I've got problem with exceptions. It is my code:
> 
> Always, always post an ENTIRE program when you ask for help. Do not

I would but my program's size is already 2000 lines. Earlier this
problem doesn't exist, it appear now. Maybe i changed sth in the code
but i dont know what it could be - so I'm asking.

Godfryd

-- 
|  Michal Nowikowski <godfryd@zamek.gda.pl>
|  BOFH excuse #122: because Bill Gates is a Jehovah's witness and so
|  nothing can work on St. Swithin's day.



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

* Re: not handled exceptions
  2002-03-23  7:09 ` Wilhelm Spickermann
  2002-03-23  9:36   ` Ingo Marks
@ 2002-03-23 13:40   ` Michal Nowikowski
  1 sibling, 0 replies; 12+ messages in thread
From: Michal Nowikowski @ 2002-03-23 13:40 UTC (permalink / raw)


On Sat, 23 Mar 2002 08:09:15 +0100, Wilhelm Spickermann wrote:

> that may an installation problem. Your Linux box comes with a gcc and
> GNAT comes with a different gcc and both are needed and may not mix up.

I've got Debian Sid with Gnat 3.14p and gcc 2.95.4. I dont if it is that
fault :/

Godfryd

-- 
|  Michal Nowikowski <godfryd@zamek.gda.pl>
|  BOFH excuse #122: because Bill Gates is a Jehovah's witness and so
|  nothing can work on St. Swithin's day.



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

* Re: not handled exceptions
  2002-03-23 13:39   ` Michal Nowikowski
@ 2002-03-23 15:13     ` Steve Doiel
  2002-03-23 17:32       ` tmoran
  2002-03-23 22:04       ` Michal Nowikowski
  0 siblings, 2 replies; 12+ messages in thread
From: Steve Doiel @ 2002-03-23 15:13 UTC (permalink / raw)


"Michal Nowikowski" <godfryd@zamek.gda.pl> wrote in message
news:pan.2002.03.23.14.39.06.84735.1206@zamek.gda.pl...
> On Sat, 23 Mar 2002 12:52:18 +0100, Robert Dewar wrote:
>
> >> I've got problem with exceptions. It is my code:
> >
> > Always, always post an ENTIRE program when you ask for help. Do not
>
> I would but my program's size is already 2000 lines. Earlier this
> problem doesn't exist, it appear now. Maybe i changed sth in the code
> but i dont know what it could be - so I'm asking.
>
Try to produce a minimal subset of the program that reproduces the problem.
For example, if the problem is in fact with unhandled exceptions, the
following program might do:

  procedure Test_Exception is
    exc : exception;
  begin
    raise exc;
  end Test_Exception;

If this doesn't reproduce the problem there is probably something else going
on.
For example, if you program includes tasks, the main program will not
terminate until all dependent tasks terminate.

SteveD

> Godfryd
>
> --
> |  Michal Nowikowski <godfryd@zamek.gda.pl>
> |  BOFH excuse #122: because Bill Gates is a Jehovah's witness and so
> |  nothing can work on St. Swithin's day.





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

* Re: not handled exceptions
  2002-03-23 15:13     ` Steve Doiel
@ 2002-03-23 17:32       ` tmoran
  2002-03-23 22:04       ` Michal Nowikowski
  1 sibling, 0 replies; 12+ messages in thread
From: tmoran @ 2002-03-23 17:32 UTC (permalink / raw)


>Try to produce a minimal subset of the program that reproduces the problem.
  That's certainly a skill any programmer needs if he ever wants to report
a compiler bug and get it fixed.  Vendors, not unreasonably, tend to
assign lower priority to "here's this massive program and it has a problem".
  Either create a small program that shows the problem or delete
successive chunks of a big program until it stops showing the problem,
then put back the chunk that caused the problem.



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

* Re: not handled exceptions
  2002-03-23 15:13     ` Steve Doiel
  2002-03-23 17:32       ` tmoran
@ 2002-03-23 22:04       ` Michal Nowikowski
  2002-03-23 23:37         ` Steve Doiel
  1 sibling, 1 reply; 12+ messages in thread
From: Michal Nowikowski @ 2002-03-23 22:04 UTC (permalink / raw)


On Sat, 23 Mar 2002 16:13:56 +0100, Steve Doiel wrote:

> For example, if you program includes tasks, the main program will not
> terminate until all dependent tasks terminate.

Yes, it is. The problem was that main program (where exception occured)
was waiting for a task. 

Is it possible to stop task while it is doing sth? Maybe i could use
this construction:

select
 ...
then abort
 ...
end select;

but how to know that exception has been raised?

Godfryd

-- 
|  Michal Nowikowski <godfryd@zamek.gda.pl>
|  BOFH excuse #288: Hard drive sleeping. Let it wake up on it's own...



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

* Re: not handled exceptions
  2002-03-23 22:04       ` Michal Nowikowski
@ 2002-03-23 23:37         ` Steve Doiel
  2002-03-24  6:47           ` Michal Nowikowski
  0 siblings, 1 reply; 12+ messages in thread
From: Steve Doiel @ 2002-03-23 23:37 UTC (permalink / raw)


Look into using the "terminate" option with a select statement.  Something
along the lines of:

  task_loop:
    loop
      select
        Do_Something;
      or
        terminate;
        exit task_loop;
      end select;
    end loop task_loop;

When you give the select a terminate option it will be taken when the
controlling task terminates.

SteveD

"Michal Nowikowski" <godfryd@zamek.gda.pl> wrote in message
news:pan.2002.03.23.23.04.35.386529.957@zamek.gda.pl...
> On Sat, 23 Mar 2002 16:13:56 +0100, Steve Doiel wrote:
>
> > For example, if you program includes tasks, the main program will not
> > terminate until all dependent tasks terminate.
>
> Yes, it is. The problem was that main program (where exception occured)
> was waiting for a task.
>
> Is it possible to stop task while it is doing sth? Maybe i could use
> this construction:
>
> select
>  ...
> then abort
>  ...
> end select;
>
> but how to know that exception has been raised?
>
> Godfryd
>
> --
> |  Michal Nowikowski <godfryd@zamek.gda.pl>
> |  BOFH excuse #288: Hard drive sleeping. Let it wake up on it's own...





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

* Re: not handled exceptions
  2002-03-23 23:37         ` Steve Doiel
@ 2002-03-24  6:47           ` Michal Nowikowski
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Nowikowski @ 2002-03-24  6:47 UTC (permalink / raw)


On Sun, 24 Mar 2002 00:37:34 +0100, Steve Doiel wrote:

>   task_loop:
>     loop
>       select
>         Do_Something;
>       or
>         terminate;
>         exit task_loop;
>       end select;
>     end loop task_loop;
> 
> When you give the select a terminate option it will be taken when the
> controlling task terminates.

I know that. But what to do if Do_Something is executing and would be for
a longer time. Could it be interupted?

Godfryd

-- 
|  Michal Nowikowski <godfryd@zamek.gda.pl>
|  BOFH excuse #203: Write-only-memory subsystem too slow for this
|  machine. Contact your local dealer.



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

end of thread, other threads:[~2002-03-24  6:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-22 17:40 not handled exceptions Michal Nowikowski
2002-03-23  0:42 ` Greg Bek
2002-03-23  7:09 ` Wilhelm Spickermann
2002-03-23  9:36   ` Ingo Marks
2002-03-23 13:40   ` Michal Nowikowski
2002-03-23 11:52 ` Robert Dewar
2002-03-23 13:39   ` Michal Nowikowski
2002-03-23 15:13     ` Steve Doiel
2002-03-23 17:32       ` tmoran
2002-03-23 22:04       ` Michal Nowikowski
2002-03-23 23:37         ` Steve Doiel
2002-03-24  6:47           ` Michal Nowikowski

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