comp.lang.ada
 help / color / mirror / Atom feed
* Gnat Version 4.5.4 v protected objects v tasking
@ 2013-04-23 20:30 stvcook53
  2013-04-23 22:03 ` Simon Wright
  0 siblings, 1 reply; 4+ messages in thread
From: stvcook53 @ 2013-04-23 20:30 UTC (permalink / raw)


Please consider sample code and comment to remedy failure in code sample or compiler.

Tried several versions of GPL Gnat Ada this year to build under x86_64 RHEL5 OS where previously succeeded with i386 OS.  Fortunately, the 4.5.4 libre gnat builds all my source code, but exhibits strange run-time symptoms using a sample that worked with older Gnat versions.  

Symptoms out of 4.5.4 relate to the tasking portion of the Ada run-time system, and relate to protected objects when located outside the main program.  Symptoms manifest as a silent hang when a program is run that includes the tasking portion of the runtime system.  The gdb debugger exhibits a SIGSEGV while in the run-time package System.Secondary_Stack.  Symptom occurs at the end of elaboration before control enters main program.  Please comment on sample code or planned, related Gnat updates.

Note: Internal compilation errors are common when trying to build my larger code using older Gnat versions in x86_64 configuration.  This includes 3.1.6, 4.1.0, and 4.3.6.  Emphasis on run-time in latest Gnat is derived from its success at building other code.

Sample code is summarized as follows:

main(Test_Protected_Object)
  with Contrived;

spec(Contrived)
body(Contrived) note: 3 types
    1. no tasking
    2. protected object
    3. task

Detailed code follows:
--main***
--Simple program to attempt to reproduce segmentation fault.

with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Command_Line;

with Contrived; -- add code actually involved in segmentation fault

procedure Test_Protected_Object is

begin  --Test_Protected_Object

   Ada.Text_IO.Put_Line("Test_Protected_Object: ");

   Ada.Text_IO.Put_Line("  The program name is "
                        & Ada.Command_Line.Command_Name);

   Ada.Text_IO.Put_Line("** before referencing protected object: ");
   Contrived.Print_This;
   Ada.Text_IO.Put_Line("*** after referencing protected object: ");

exception
 when E:others =>
   Ada.Text_IO.Put_Line("** unexpected exception "
                        & Ada.Exceptions.Exception_Name(E));
end Test_Protected_Object;

--spec(Contrived) ***
-------------------------------------------------------------------------------
-- Contrived package containing:
--   a.  no tasking
--   b.  a protected object
--   c.  a task
-- in the package body, depending upon which configuration I which to test.
-------------------------------------------------------------------------------

package Contrived is

   procedure Print_This;

end Contrived;

--body(Contrived - Option A no symptom) ***
-------------------------------------------------------------------------------
-- Contrived package containing:
--   a.  no tasking
--   b.  a protected object
--   c.  a task
-- in the package body, depending upon which configuration I which to test.
-------------------------------------------------------------------------------

-- this is configuration a.
with Ada.Text_IO;

package body Contrived is

   procedure Print_This is
   begin
      Ada.Text_IO.Put_Line("Contrived:  Print_This");
   end Print_This;

end Contrived;

--body(Contrived - Option B symptom) ***
-------------------------------------------------------------------------------
-- Contrived package containing:
--   a.  no tasking
--   b.  a protected object
--   c.  a task
-- in the package body, depending upon which configuration I which to test.
-------------------------------------------------------------------------------

-- this is configuration b.
with Ada.Text_IO;

package body Contrived is

   protected Object is
      procedure Print_That;
   end Object;

   protected body Object is
      procedure Print_That is
      begin
         Ada.Text_IO.Put_Line("Contrived.Object.Print_That");
      end Print_That;
   end Object;

   procedure Print_This is
   begin
      Ada.Text_IO.Put_Line("Contrived:  Print_This");
      Object.Print_That;
   end Print_This;

end Contrived;

--body(Contrived - Option C same symptom) ***
-------------------------------------------------------------------------------
-- Contrived package containing:
--   a.  no tasking
--   b.  a protected object
--   c.  a task
-- in the package body, depending upon which configuration I which to test.
-------------------------------------------------------------------------------

-- this is configuration c.
with Ada.Text_IO;

package body Contrived is

   task Object is
      entry Print_That;
   end Object;

   task body Object is
   begin
      loop
         select
            accept Print_That;
            Ada.Text_IO.Put_Line("Contrived.Object.Print_That");
         or
            terminate;
         end select;
      end loop;
   end Object;

   procedure Print_This is
   begin
      Ada.Text_IO.Put_Line("Contrived:  Print_This");
      Object.Print_That;
   end Print_This;

end Contrived;



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

* Re: Gnat Version 4.5.4 v protected objects v tasking
  2013-04-23 20:30 Gnat Version 4.5.4 v protected objects v tasking stvcook53
@ 2013-04-23 22:03 ` Simon Wright
  2013-04-24 13:21   ` stvcook53
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Wright @ 2013-04-23 22:03 UTC (permalink / raw)


stvcook53@gmail.com writes:

> Symptoms out of 4.5.4 relate to the tasking portion of the Ada
> run-time system, and relate to protected objects when located outside
> the main program.  Symptoms manifest as a silent hang when a program
> is run that includes the tasking portion of the runtime system.  The
> gdb debugger exhibits a SIGSEGV while in the run-time package
> System.Secondary_Stack.  Symptom occurs at the end of elaboration
> before control enters main program.  Please comment on sample code or
> planned, related Gnat updates.

No problems here on Mac OS X - x86_64 - with GNAT GPL 2011/2 or with FSF
4.8.0.

I don't see anything wrong with your code.

The symptoms sound as though the tasking part of the RTS isn't getting
initialised (or not properly, anyway).

I had related symptoms when I had a library that involved tasking and a
main program that didn't; you don't have a separate library, but could
you perhaps try linking with the static RTS vs linking with the dynamic
RTS? If you're using gnatmake, add "-bargs -static" or "-bargs -shared",
or if you're running gnatbind by hand it's "gnatbind -static" or
"gnatbind -shared".



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

* Re: Gnat Version 4.5.4 v protected objects v tasking
  2013-04-23 22:03 ` Simon Wright
@ 2013-04-24 13:21   ` stvcook53
  2013-04-29 13:15     ` stvcook53
  0 siblings, 1 reply; 4+ messages in thread
From: stvcook53 @ 2013-04-24 13:21 UTC (permalink / raw)


On Tuesday, April 23, 2013 5:03:12 PM UTC-5, Simon Wright wrote:
> stvcook53@gmail.com writes:
> 
> 
> 
> > Symptoms out of 4.5.4 relate to the tasking portion of the Ada
> 
> > run-time system, and relate to protected objects when located outside
> 
> > the main program.  Symptoms manifest as a silent hang when a program
> 
> > is run that includes the tasking portion of the runtime system.  The
> 
> > gdb debugger exhibits a SIGSEGV while in the run-time package
> 
> > System.Secondary_Stack.  Symptom occurs at the end of elaboration
> 
> > before control enters main program.  Please comment on sample code or
> 
> > planned, related Gnat updates.
> 
> 
> 
> No problems here on Mac OS X - x86_64 - with GNAT GPL 2011/2 or with FSF
> 
> 4.8.0.
> 
> 
> 
> I don't see anything wrong with your code.
> 
> 
> 
> The symptoms sound as though the tasking part of the RTS isn't getting
> 
> initialised (or not properly, anyway).
> 
> 
> 
> I had related symptoms when I had a library that involved tasking and a
> 
> main program that didn't; you don't have a separate library, but could
> 
> you perhaps try linking with the static RTS vs linking with the dynamic
> 
> RTS? If you're using gnatmake, add "-bargs -static" or "-bargs -shared",
> 
> or if you're running gnatbind by hand it's "gnatbind -static" or
> 
> "gnatbind -shared".


Thanks Simon.  My coworker will be happy that you work with Mac.  We'll check it out.

Steve



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

* Re: Gnat Version 4.5.4 v protected objects v tasking
  2013-04-24 13:21   ` stvcook53
@ 2013-04-29 13:15     ` stvcook53
  0 siblings, 0 replies; 4+ messages in thread
From: stvcook53 @ 2013-04-29 13:15 UTC (permalink / raw)


On Wednesday, April 24, 2013 8:21:37 AM UTC-5, stvc...@gmail.com wrote:
> On Tuesday, April 23, 2013 5:03:12 PM UTC-5, Simon Wright wrote:
> 
> > stvcook53@gmail.com writes:
> 
> > 
> 
> > 
> 
> > 
> 
> > > Symptoms out of 4.5.4 relate to the tasking portion of the Ada
> 
> > 
> 
> > > run-time system, and relate to protected objects when located outside
> 
> > 
> 
> > > the main program.  Symptoms manifest as a silent hang when a program
> 
> > 
> 
> > > is run that includes the tasking portion of the runtime system.  The
> 
> > 
> 
> > > gdb debugger exhibits a SIGSEGV while in the run-time package
> 
> > 
> 
> > > System.Secondary_Stack.  Symptom occurs at the end of elaboration
> 
> > 
> 
> > > before control enters main program.  Please comment on sample code or
> 
> > 
> 
> > > planned, related Gnat updates.
> 
> > 
> 
> > 
> 
> > 
> 
> > No problems here on Mac OS X - x86_64 - with GNAT GPL 2011/2 or with FSF
> 
> > 
> 
> > 4.8.0.
> 
> > 
> 
> > 
> 
> > 
> 
> > I don't see anything wrong with your code.
> 
> > 
> 
> > 
> 
> > 
> 
> > The symptoms sound as though the tasking part of the RTS isn't getting
> 
> > 
> 
> > initialised (or not properly, anyway).
> 
> > 
> 
> > 
> 
> > 
> 
> > I had related symptoms when I had a library that involved tasking and a
> 
> > 
> 
> > main program that didn't; you don't have a separate library, but could
> 
> > 
> 
> > you perhaps try linking with the static RTS vs linking with the dynamic
> 
> > 
> 
> > RTS? If you're using gnatmake, add "-bargs -static" or "-bargs -shared",
> 
> > 
> 
> > or if you're running gnatbind by hand it's "gnatbind -static" or
> 
> > 
> 
> > "gnatbind -shared".
> 
> 
> 
> 
> 
> Thanks Simon.  My coworker will be happy that you work with Mac.  We'll check it out.
> 
> 
> 
> Steve

We enjoyed good operation of the test program with your suggestion.
Thanks,
Steve



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

end of thread, other threads:[~2013-04-29 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-23 20:30 Gnat Version 4.5.4 v protected objects v tasking stvcook53
2013-04-23 22:03 ` Simon Wright
2013-04-24 13:21   ` stvcook53
2013-04-29 13:15     ` stvcook53

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