[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Next version of libtemplates-parser in Debian



On 05/23/2011 06:01 PM, Pascal Obry wrote:
> 
> Xavier,
> 
>> Any idea how to fix/solve this ?
> 
> Probably because templates parser use a construct that require a
> trampoline (there is still rare case like this in GNAT). So there is
> probably no way to fix that.

Actually these cases are not so rare. As soon as you use Ada.Containers
you are almost there. 'Access to a nested function is enough. The
following code illustrates this:

--

with Ada.Containers.Ordered_Sets;

procedure Execstack is

   package My_Set is new Ada.Containers.Ordered_Sets
     (Element_Type => Integer);

   Set : My_Set.Set;

   procedure Nested (Position : My_Set.Cursor)
   is
   begin
      null;
   end Nested;

begin
   Set.Iterate (Process => Nested'Access);
end Execstack;

--

The stack of the resulting binary is executable:

GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    8

Tested with gnat in Lenny, Squeeze and sid (amd64/i386).

It's interesting that the same code compiled with GNAT GPL 2010 does not
result in an executable stack:

GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     8

Since an executable stack is not very nice I think it would be
interesting if we could identify the patch which is responsible for this
behavior. Maybe we could port it to work with 4.6.0.

- reto


Reply to: