comp.lang.ada
 help / color / mirror / Atom feed
* GNAT bug with protected procedure interrupt handler
@ 2016-06-25  2:40 Daniel King
  2016-06-25  5:27 ` Egil H H
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel King @ 2016-06-25  2:40 UTC (permalink / raw)


I'm working on a project using GNAT GPL 2016 and AdaCore's ravenscar-sfp-stm32f4 runtime and I am encountering GNAT bugs when using the Attach_Handler aspect/pragma on a protected procedure.

More specifically, given the following (trivial) code:

    with Ada.Interrupts.Names;
    with System;

    package IRQ_Test
    is
       protected type IRQ_Test_Type
       is
          procedure Handle_IRQ
            with Attach_Handler => Ada.Interrupts.Names.RTC_Interrupt;
       end IRQ_Test_Type;
    end IRQ_Test;

I encounter the following GNAT bug message:

    +===========================GNAT BUG DETECTED==============================+
    | GPL 2016 (20160515-49) (arm-eabi) Program_Error sem_type.adb:814 explicit raise|
    | Error detected at irq_test.ads:6:4                                       |
    | Please submit a bug report by email to report@adacore.com.               |
    | GAP members can alternatively use GNAT Tracker:                          |
    | http://www.adacore.com/ section 'send a report'.                         |
    | See gnatinfo.txt for full info on procedure for submitting bugs.         |
    | Use a subject line meaningful to you and us to track the bug.            |
    | Include the entire contents of this bug box in the report.               |
    | Include the exact command that you entered.                              |
    | Also include sources listed below.                                       |
    | Use plain ASCII or MIME attachment(s).                                   |
    +==========================================================================+

    Please include these source files with error report
    Note that list may not be accurate in some cases,
    so please double check that the problem can still
    be reproduced with the set of files listed.
    Consider also -gnatd.n switch (see debug.adb).

    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/arch/system.ads
    /home/dan/projects/ada/stm32test/irq_test.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/ada.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/a-interr.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-interr.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-taskin.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/a-unccon.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/s-stoele.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/s-parame.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-tasinf.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-taspri.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-osinte.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-multip.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/s-bb.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-arch/s-bbpara.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/interfac.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/i-stm32.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/i-stm32-rcc.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/i-bit_types.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/s-stm32.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/s-bbbopa.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/s-bbmcpa.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/bsp/i-stm32-pwr.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbthre.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbcppr.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbtime.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbinte.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bcprmu.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbthqu.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-bbbosu.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-taprob.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-mufalo.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-musplo.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/s-tposen.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-common/a-taside.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/gnarl-bsp/a-intnam.ads
    /usr/gnat/arm-eabi/lib/gnat/ravenscar-sfp-stm32f4/common/s-unstyp.ads

If I omit the Attach_Handler line on my original example then there are no errors.

Has anyone else seen this problem, or are able to reproduce it? Have you found a workaround?

Daniel


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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25  2:40 GNAT bug with protected procedure interrupt handler Daniel King
@ 2016-06-25  5:27 ` Egil H H
  2016-06-25  7:28   ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: Egil H H @ 2016-06-25  5:27 UTC (permalink / raw)


On Saturday, June 25, 2016 at 4:40:31 AM UTC+2, Daniel King wrote:
> 
> Has anyone else seen this problem, or are able to reproduce it? Have you found a workaround?
> 

Your code works here (except that RTC_Interrupt does not exist, so I changed it to RCC_Interrupt)

-- 
~egilhh

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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25  5:27 ` Egil H H
@ 2016-06-25  7:28   ` Simon Wright
  2016-06-25 12:27     ` Daniel King
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2016-06-25  7:28 UTC (permalink / raw)


Egil H H <ehh.public@gmail.com> writes:

> On Saturday, June 25, 2016 at 4:40:31 AM UTC+2, Daniel King wrote:
>> 
>> Has anyone else seen this problem, or are able to reproduce it? Have
>> you found a workaround?
>> 
>
> Your code works here (except that RTC_Interrupt does not exist, so I
> changed it to RCC_Interrupt)

Likewise.

Compiling with -gnatG (shows a representation of the intermediate code)
sometimes shows up a problem.


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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25  7:28   ` Simon Wright
@ 2016-06-25 12:27     ` Daniel King
  2016-06-25 13:15       ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel King @ 2016-06-25 12:27 UTC (permalink / raw)


On Saturday, 25 June 2016 04:28:01 UTC-3, Simon Wright  wrote:
> Egil H H <ehh.public@gmail.com> writes:
> 
> > On Saturday, June 25, 2016 at 4:40:31 AM UTC+2, Daniel King wrote:
> >> 
> >> Has anyone else seen this problem, or are able to reproduce it? Have
> >> you found a workaround?
> >> 
> >
> > Your code works here (except that RTC_Interrupt does not exist, so I
> > changed it to RCC_Interrupt)
> 
> Likewise.
> 
> Compiling with -gnatG (shows a representation of the intermediate code)
> sometimes shows up a problem.

Thanks, whilst trying your suggestion I realised that actually, the code *compiles* fine for me too, the failure seems to occur only when using -gnatc to check syntax/semantics only. When I first posted I had not yet compiled the code because I was checking my .ads file since I had not yet written a corresponding .adb file to compile.

So although the GNAT bug still occurs when using -gnatc at least the code compiles fine so I can still continue with my project.

Thanks!

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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25 12:27     ` Daniel King
@ 2016-06-25 13:15       ` Simon Wright
  2016-06-25 14:27         ` Daniel King
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2016-06-25 13:15 UTC (permalink / raw)


Daniel King <daniel.dmk@googlemail.com> writes:

> On Saturday, 25 June 2016 04:28:01 UTC-3, Simon Wright  wrote:
>> Egil H H <ehh.public@gmail.com> writes:
>> 
>> > On Saturday, June 25, 2016 at 4:40:31 AM UTC+2, Daniel King wrote:
>> >> 
>> >> Has anyone else seen this problem, or are able to reproduce it? Have
>> >> you found a workaround?
>> >> 
>> >
>> > Your code works here (except that RTC_Interrupt does not exist, so I
>> > changed it to RCC_Interrupt)
>> 
>> Likewise.
>> 
>> Compiling with -gnatG (shows a representation of the intermediate code)
>> sometimes shows up a problem.
>
> Thanks, whilst trying your suggestion I realised that actually, the
> code *compiles* fine for me too, the failure seems to occur only when
> using -gnatc to check syntax/semantics only. When I first posted I had
> not yet compiled the code because I was checking my .ads file since I
> had not yet written a corresponding .adb file to compile.
>
> So although the GNAT bug still occurs when using -gnatc at least the
> code compiles fine so I can still continue with my project.

You appear to have come across another instance of PR66162! Yours is an
instance of comment 4.

I still don't know what the language restrictions for building the
runtime are; I think that they relate to RTS units that the compiler
relies on to generate calls into the RTS, for instance for POs. So far,
off the top of my head, I have

* no private withs
* no 'use' clauses in the spec
* no visibility of non-System, non-Interface packages
* no package aspects (not sure about this)

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66162


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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25 13:15       ` Simon Wright
@ 2016-06-25 14:27         ` Daniel King
  2016-06-25 14:34           ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel King @ 2016-06-25 14:27 UTC (permalink / raw)


On Saturday, 25 June 2016 10:15:12 UTC-3, Simon Wright  wrote:
> Daniel King writes:
> 
> > On Saturday, 25 June 2016 04:28:01 UTC-3, Simon Wright  wrote:
> >> Egil H H <ehh.public@gmail.com> writes:
> >> 
> >> > On Saturday, June 25, 2016 at 4:40:31 AM UTC+2, Daniel King wrote:
> >> >> 
> >> >> Has anyone else seen this problem, or are able to reproduce it? Have
> >> >> you found a workaround?
> >> >> 
> >> >
> >> > Your code works here (except that RTC_Interrupt does not exist, so I
> >> > changed it to RCC_Interrupt)
> >> 
> >> Likewise.
> >> 
> >> Compiling with -gnatG (shows a representation of the intermediate code)
> >> sometimes shows up a problem.
> >
> > Thanks, whilst trying your suggestion I realised that actually, the
> > code *compiles* fine for me too, the failure seems to occur only when
> > using -gnatc to check syntax/semantics only. When I first posted I had
> > not yet compiled the code because I was checking my .ads file since I
> > had not yet written a corresponding .adb file to compile.
> >
> > So although the GNAT bug still occurs when using -gnatc at least the
> > code compiles fine so I can still continue with my project.
> 
> You appear to have come across another instance of PR66162! Yours is an
> instance of comment 4.
> 
> I still don't know what the language restrictions for building the
> runtime are; I think that they relate to RTS units that the compiler
> relies on to generate calls into the RTS, for instance for POs. So far,
> off the top of my head, I have
> 
> * no private withs
> * no 'use' clauses in the spec
> * no visibility of non-System, non-Interface packages
> * no package aspects (not sure about this)
> 
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66162

Thanks for that, Simon.

When I get some time I will look into the runtime to see if I can find any restriction violations.

Did you ever find a write-up of the runtime language restrictions?

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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25 14:27         ` Daniel King
@ 2016-06-25 14:34           ` Simon Wright
  2016-06-30 16:00             ` Daniel King
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2016-06-25 14:34 UTC (permalink / raw)


Daniel King <daniel.dmk@googlemail.com> writes:

> Did you ever find a write-up of the runtime language restrictions?

No: I asked twice (three times?) and got no answer.


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

* Re: GNAT bug with protected procedure interrupt handler
  2016-06-25 14:34           ` Simon Wright
@ 2016-06-30 16:00             ` Daniel King
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel King @ 2016-06-30 16:00 UTC (permalink / raw)


Update:

I sent a bug report to AdaCore and apparently it's a bug in the compiler, not the runtime. So it seems that this is a different problem to PR66162.

In the meantime I'm continuing with avoiding -gnatc for the affected files in my project.

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

end of thread, other threads:[~2016-06-30 16:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-25  2:40 GNAT bug with protected procedure interrupt handler Daniel King
2016-06-25  5:27 ` Egil H H
2016-06-25  7:28   ` Simon Wright
2016-06-25 12:27     ` Daniel King
2016-06-25 13:15       ` Simon Wright
2016-06-25 14:27         ` Daniel King
2016-06-25 14:34           ` Simon Wright
2016-06-30 16:00             ` Daniel King

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