DBMonitor & Dll issue - no log

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

DBMonitor & Dll issue - no log

Post by Louarn » Tue 19 Aug 2014 13:56

Hello all,

I have an issue with my dll and DB monitor since we upgrade our component to the 9.3.6 version.
Previously, we were in 8.3.11, and currently using delphi xe3.

Here is the pb: we have a application which call a DLL.
The application SQL is logged fine in DB Monitor, but not the SQL from de DLL.

In the dll, we have deactivated the SQL Monitor (removing the TOraSqlMonitor.create)

You will says: "hey dude, this is the fu*k !".

Well, in fact, yes and no.

When we have the "TOraSqlMonitor.create" in the dll, the loading of the dll hangs and never get back.
I am pretty sure that this is due to this line of code, in DBMonitorClient.pas:

Code: Select all

     constructor TEventSendThread.Create(DBMonitor: TDBMonitor);
     begin
       inherited Create(True);
     
       FConnectEvent := TEvent.Create(nil, True, False, '');
       FEndEvent := TEvent.Create(nil, True, False, '');
     {$IFDEF CLR}
       Handle.IsBackGround := True;
     {$ENDIF}
       FDBMonitor := DBMonitor;
     
       Resume;
       if IsLibrary then
--->     FConnectEvent.WaitFor(INFINITE);
     end;

I do not have the source code of the version 8.3.11 (or previous) of this file, but this line of code seems to be here at least since te revision 8.6.12.

Has anyone have the history of this file, or encounter this kind of issue ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Wed 20 Aug 2014 12:00

Hello,

Try to reproduce the problem on the latest ODAC version 9.3.10. If the problem repeats, please send us a sample reproducing the problem to alexp*devart*com.

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Wed 20 Aug 2014 15:06

Hello Alex,

I have send you a mail with the source code.
In fact, very simple: just try to load a dll with a sql monitor in it.
This hangs.

App. code:

Code: Select all

unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Form2       : TForm2;
  DllHandle   : THandle;
implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
  try
    DllHandle := LoadLibrary (Pchar(Edit1.Text));
  except
   ShowMessage(SysErrorMessage(GetLastError));
  end;
end;

end.
Dll dpr code:

Code: Select all

library MyDll;
uses
  System.SysUtils,
  System.Classes,
  orasqlmonitor;

{$R *.res}
var  gorasqlmonitor : TOrasqlmonitor;

begin
  //gorasqlmonitor := TOraSqlMonitor.create(nil);
end.
If you uncomment the TOraSqlMonitor.create(nil), the application will hang when loading the dll.

Hope this can help you finding the issue !

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Thu 21 Aug 2014 09:58

Thank you for the information. We have reproduced the problem and will investigate the reasons of such behavior.

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Thu 21 Aug 2014 15:19

Ok, nice to see that I am not alone with this pb.

Please keep me in touch if you find a solution !

Thanks.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Tue 26 Aug 2014 08:04

We will inform you as soon as we have any results.

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Thu 18 Sep 2014 08:30

Hello,

Is there any news on this issue ?
I mean, if a correction has been identified or planned ?

Thanks !

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Thu 18 Sep 2014 12:29

We have investigated the problem more deeply and found out that, when dll is loading, the OS doesn't run other threads (and SQLMonitor uses threads), and we can't know whether the DLL was loaded or not.

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Thu 25 Sep 2014 12:48

Hello Alex,

Do you mean that this issue will not meet a solution ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Fri 26 Sep 2014 11:09

You should create ToraSQLMonitor in a separate method, and call this method after DLL is loaded.

Code: Select all

program MainProject;

{$APPTYPE CONSOLE}

uses
  SysUtils, Windows;
type
  TCreateOraSQLMonitor = procedure;stdcall;
var
   DllHandle: THandle;
   CreateOraSQLMonitor: TCreateOraSQLMonitor;
begin
  try
    DllHandle := LoadLibrary (Pchar('DllProject.dll'));
    CreateOraSQLMonitor := GetProcAddress(DllHandle, 'CreateOraSQLMonitor');
    CreateOraSQLMonitor;
  except
   Writeln(SysErrorMessage(GetLastError));
  end;
  readln;
end.

Code: Select all

library DllProject;

uses
  SysUtils,
  Classes,
  orasqlmonitor, DBMonitorClient, Ora;

{$R *.res}
var
  gorasqlmonitor : TOrasqlmonitor;

procedure CreateOraSQLMonitor;
begin
  gorasqlmonitor := TOrasqlmonitor.Create(nil);
end;

exports
  CreateOraSQLMonitor;

begin
end.

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Fri 26 Sep 2014 11:55

Thanks AlexP, I will try and revert if it is Ko.

Don't be afraid, I will revert also if it is fine !

Louarn
Posts: 10
Joined: Tue 19 Aug 2014 13:33

Re: DBMonitor & Dll issue - no log

Post by Louarn » Thu 09 Oct 2014 12:09

Hello AlexP,

Seems to be fine with this way of doing.
Calling in the application a method of the dll in order to start the Sql Monitor is ok !

Thanks.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBMonitor & Dll issue - no log

Post by AlexP » Thu 09 Oct 2014 13:54

Hello,

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply