RO DataSnap: Client doesn't close all threads on excpetion at server

Hello,

when the TRODataSnapModule raises an exception on the server, the client catches that exception, but keeps an thread running. So when I close the client, it doesn’t close at all. It’s still running in the background.

See attached sample:
RO DataSnap DllChannel.zip (2.2 MB)

When you run the sample the Delphi IDE you will get a “database not connected” error, and the debugger doesn’t close when you close the client. You will also notice that there an additional thread running.

I can’t reproduce this issue.

my steps:

  • project in debug mode was launched
  • Open button was pressed
  • I received exceptions in debugger and
---------------------------
Dllchannelserverclient
---------------------------
Cannot locate C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\RAD Studio\Projekte\RO DataSnap DllChannel\DLLChannelServer.dll.
---------------------------
OK   
---------------------------
  • application was closed

Please change the dll path in the TRODLLChannel compoenent in the client project, regarding your directory. I had to hardcode that path in order the IDE could find the dll server.

In this case I’ve

---------------------------
Debugger Exception Notification
---------------------------
Project DLLChannelServerClient.exe raised exception class EIBInterBaseError with message 'unavailable database'.
---------------------------
Break   Continue   Help   
---------------------------

and later this exception in loop:

---------------------------
Debugger Exception Notification
---------------------------
Project DLLChannelServerClient.exe raised exception class $C0000025 with message 'non-continuable exception at 0x7739017c'.
---------------------------
Break   Continue   Help   
---------------------------

later

---------------------------
Debugger Exception Notification
---------------------------
Project DLLChannelServerClient.exe raised exception class $C00000FD with message 'stack overflow at 0x77363792'.
---------------------------
Break   Continue   Help   
---------------------------

all these exceptions were raised in IBX.IB.pas at

procedure IBDataBaseError(FGDSLibrary : IGDSLibrary);
..
    raise EIBInterBaseError.Create(sqlcode, IBErrorCode, usr_msg)  //<<<<<<<<<<< here
  else
    raise EIBInterBaseRoleError.Create(sqlcode, IBErrorCode, usr_msg)
end;

When you close the appliction, is there also an invisible process running in the background or in debug mode, the debugger doesn’t close, since there is a hidden thread running?

The point is, when I use the IBX component in a single exe application, I don’t have that “hanging” thread and program closes. It seems it is related to the DLL and threading.

Do you have any hints, how I can get rid of that “hanging” thread?

I can’t close/contitue application because when I ignore those errors in debugger, I have this exception in loop :

---------------------------
Debugger Exception Notification
---------------------------
Project DLLChannelServerClient.exe raised exception class $C0000005 with message 'access violation at 0x77310125: read of address 0x00090e84'.
---------------------------
Break   Continue   Help   
---------------------------

I can recommend to recompile your project and .dll with “use debug .dcus” option.
this allow to see problems inside native delphi code.

Re this issue, I can recommend to change IBX to something else, like DBX/FireDAC or other DB library.

Found the issue.
The IBX components are using internally a IBSQLMonitorHook which creates a seperate thread, but doesn’t close it when used in DLLs.

Workaround: I disabled the IBSQLMonitorHook globally.

uses IBSQLMonitor

MonitorHook.Enabled := false;