From: Aurele <aurele.vitali@gmail.com>
Subject: Application Crashes when linked with DLL
Date: Tue, 12 Jul 2016 12:50:05 -0700 (PDT)
Date: 2016-07-12T12:50:05-07:00 [thread overview]
Message-ID: <fdde56ea-05e6-406d-b129-00839c02c7e4@googlegroups.com> (raw)
Hi o/, I'm working with Gautier and we stumbled on an interesting program behavior and thought of sharing it with you for comments. We are using the latest version (2016) of Adacore GNAT programming studio. Here is the problem:
Create a dynamic link library (DLL) and link it to an separate application. The application crashes with the message "This application as requested the runtime to terminate in an unusual way. Specifically, the problem is caused by the exception block in the application. Remove it and all is well.
-- ****************************************************************** --
-- The DLL (Dynamic Link Library)
-- ****************************************************************** --
package Dll_Name is
procedure DLL_Test_Procedure( s : Integer := 0 );
private
pragma export( Ada, DLL_Test_Procedure, "DLL_Test_Procedure" );
end Dll_Name;
with Ada.Text_IO;
package body Dll_Name is
procedure DLL_Test_Procedure( s : Integer := 0 ) is
Item : String (1 .. 80);
Last : Natural;
begin
Ada.Text_IO.Put( "Hello World from 'DLL_Test_Procedure'... : " );
Ada.Text_IO.Put_Line( Integer'image( s ) );
Ada.Text_IO.Get_Line( Item, Last );
end DLL_Test_Procedure;
end Dll_Name;
-- The Import Spec (used by the application)
package Dll_Name_Imports is
procedure DLL_Test_Procedure( s : Integer := 0 );
private
pragma import( Ada, DLL_Test_Procedure, "DLL_Test_Procedure" );
end Dll_Name_Imports;
-- ****************************************************************** --
-- The Application
-- ****************************************************************** --
with Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
with Dll_Name_Imports;
procedure Dll_Name_Tester is
procedure Trace( s: String ) is
begin
Ada.Text_IO.Put_Line( Ada.Text_IO.Current_Error, s );
end Trace;
begin
-- Problem block (if removed everything works fine)
declare
Constraint_Error : exception;
begin
raise Constraint_Error with "Exception caught.";
exception
when Fail : Constraint_Error => Trace( Exception_Message ( Fail ) );
end;
--
Dll_Name_Imports.DLL_Test_Procedure( 1955 ); -- This normally works fine
end Dll_Name_Tester;
-- ****************************************************************** --
The application (and the exception) work fine if its not linked with the DLL.
So I'm stumped !
next reply other threads:[~2016-07-12 19:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 19:50 Aurele [this message]
2016-07-12 23:08 ` Application Crashes when linked with DLL rieachus
2016-07-13 0:16 ` Aurele
2016-07-13 17:06 ` Aurele
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox