public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: KUHLMANCJ@NSWC.NAVY.MIL
To: gcc-gnats@gcc.gnu.org
Subject: ada/6946: problem with Ada DLL made with GNAT, invoked by C code
Date: Thu, 06 Jun 2002 06:56:00 -0000	[thread overview]
Message-ID: <20020606135113.13074.qmail@sources.redhat.com> (raw)


>Number:         6946
>Category:       ada
>Synopsis:       problem with Ada DLL made with GNAT, invoked by C code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 06 06:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     chris kuhlman
>Release:        gnat3.14
>Organization:
>Environment:
Windows NT4.0
>Description:
I have C source.  Compile with MS Visual Studio C++ 6.0.
I have an Ada DLL.  Compiled with gnat 3.14.
The main is in C.

There is a problem with Ada input and output (I/O) initialization and finalization when an Ada DLL that has I/O is initialized and finalized more than one time from within a C code.  It is detailed below.

I have initialize and finalize invocations in the C code for the Ada procedures contained in the DLL.  If I execute the code once through, all is fine.  If, however, I put a FOR loop (say five loops) around the C code (with the initialize and finalize routines for the Ada DLL inside of the FOR loop), then the code sometimes bombs out.  When it bombs and when the program does not bomb is given next.

If the Ada procs invoked from the C code just do manipulations of variables (e.g., calculations), then the code will run fine.  However, if there is I/O in the Ada procs, then the code will bomb on the second time through.  It will bomb via an Ada.io_exceptions.status_error on line 169 of file s-fileio.adb.

It seems to me that if one invokes initialize and finalize, in pairs, each time through the loop, then the I/O should work; there should be no error.  That is, finalize should leave the code in a state such that the next initialize can indeed properly initialize the DLL.  Granted, one can just put the intialize and finalize at the beginning and end, respectively, of the C code.  However, when working with Java and JNI (composing a Java-C-Ada program), it is soemtimes most beneficial to issue initialize and finalize from the C code each time the C code (and the Ada DLL) is invoked from Java/JNI.  Furthermore, it is inconsistent to have the set of five (in this case) initialize and finalize invocations work for some Ada DLL uses and not for others.
>How-To-Repeat:
Please email me with your address and I'll email you the source files.  I have three small C source files, a few small Ada source code files, a batch file that compiles the Ada code and builds the DLL, the Ada definition file, and short instructions on how to modify the cmain25.c so that the code will and will not run correctly.
>Fix:
It seems to me that the fix is that Ada I/O should work with multiple initializations and finalizations of a single Ada DLL within one execution of a program (C the calling (main) source), as long as each initialization is accompanied by a finalization.

Thank you.
Chris Kuhlman 540-653-4721
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-06-06 13:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-06  6:56 KUHLMANCJ [this message]
2002-06-07  0:40 fw
2002-06-07  0:46 Florian Weimer
2003-01-01 18:41 neroden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020606135113.13074.qmail@sources.redhat.com \
    --to=kuhlmancj@nswc.navy.mil \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).