This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ada/6946: problem with Ada DLL made with GNAT, invoked by C code


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]