Recent

Author Topic: Need help with Indy IdTCPServer  (Read 1255 times)

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #30 on: July 06, 2026, 09:17:43 am »
I complied your server code just changed a couple of uses for linux, the client can still crash it.
This picked up no exception. just instant crash
Code: Pascal  [Select][+][-]
  1. procedure TTestServer.IdTCPServer1Exception(AContext: TIdContext;
  2.   AException: Exception);
  3. begin
  4.   WriteLn(AException.Message);
  5.   AContext.Connection.Disconnect;
  6. end;
  7.  

I cannot replicate it in Windows, it never crash.
And it doesn't matter whether I shut down and restart the server or the client (testing for stability and reliability), everything works as it should.

I can try replicating this with Delphi under Linux and see if it's stable or if there are any issues.

But I don't think it's an Indy problem: I've been using it for decades and have never had any stability issues.

I'll do some testing.
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #31 on: July 06, 2026, 10:40:21 am »
I tried with Delphi in Linux (Ubuntu 22.04 LTS) , same code, with IndySec or Taurus on Server Side and ....

it's like you said: the server crash with "segmentation fault(11)".

It's something about string compare (looking with debugger) with simd instruction, but not in direct space application: I have to debug more deep.

Very weird  :(

There will be lot of time waiting since some Linux update (unattended  %) ) have locked my Linux machine.
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

TheMouseAUS

  • Full Member
  • ***
  • Posts: 136
Re: Need help with Indy IdTCPServer
« Reply #32 on: July 06, 2026, 12:01:21 pm »
Im glad you have managed to reproduce it, I was starting to think it was just me :-)

I tried with both TaurusTLS and IndySec they both crash with a misbehaving/poorly coded client.
I only came across this figuring out how to use both TCPclient and TCPserver, If I coded it properly from the start I never would have come across it.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12942
  • FPC developer.
Re: Need help with Indy IdTCPServer
« Reply #33 on: July 06, 2026, 01:02:06 pm »
synchronize the writeln?

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #34 on: July 06, 2026, 01:59:42 pm »
synchronize the writeln?

BTW, I think you don't need to worry about writeln in fpc, since it is, unlike Delphi,  fully serialized already?

But, anyway, I try it too ....
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #35 on: July 06, 2026, 04:39:37 pm »
Now it's OK. All works

 :D

The fault with Delphi in Linux was something about FMXLinux (the application layer in Linux for Delphi, based on GTK3) with the two applications. Alone they works, together they crashed (one or the other).

Now I ported the server part to pure console and everything is working perfectly, nothing crashes.

I update in some minutes and attach here the project (only two source 'cause it was in Delphi). May be some adjustement in FPC to compile.

Take care:

The client should have the TIMER  -> NOT ACTIVE  by default !!!, until the end of FormCreate event.

And that part of code should be modified in client application (timer event):

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Timer1Timer(Sender: TObject);
  2. var s : String;
  3. begin
  4.   Log('Enter');
  5.   Timer1.Enabled := false;
  6.  
  7.   //Do not trust on ConnectionEstablished use IdTCPClient1.Connected
  8.   if not IdTCPClient1.Connected then
  9.     try
  10.       Log('Try Connection');
  11.       IdTCPClient1.Connect(ServerIP, 15577);
  12.     except
  13.       Log('Except on connection');
  14.       //Doesn't need that
  15.       //IdTCPClient1.Disconnect;
  16.       Timer1.enabled := true;
  17.       exit;
  18.     end;
  19.  
  20.   //Do not trust on ConnectionEstablished use IdTCPClient1.Connected
  21.   if IdTCPClient1.Connected  then
  22.     try
  23.       Log('Send');
  24.       IdTCPClient1.IOHandler.WriteLn('Hello');
  25.       IdTCPClient1.Disconnect; // this will crash the server if ssl enabled;
  26.       //This will LOCK the CLIENT, if you don't use timeout
  27.       if IdTCPClient1.Connected then
  28.         begin
  29.           Log('Read');
  30.           s := IdTCPClient1.IOHandler.ReadLn(sLineBreak,1000) ;
  31.           Memo1.Lines.Add(s);
  32.         end;
  33.     except on e:exception do
  34.       Log('exception on block');
  35.     end;
  36.   Timer1.enabled := true;
  37.   Log('Exit');
  38. end;
« Last Edit: July 06, 2026, 05:27:05 pm by LeP »
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #36 on: July 06, 2026, 08:35:01 pm »
I think that Linux crash may be related to: https://github.com/IndySockets/Indy/issues/682

TaurusTLS made a pacth but the full solution is made with last Indy commit.
From what I understand, this change is actually a workaround for a standard OpenSSL behavior, which is what causes the problem.
OpenSSL version 4 does not have this behavior.
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

TheMouseAUS

  • Full Member
  • ***
  • Posts: 136
Re: Need help with Indy IdTCPServer
« Reply #37 on: July 07, 2026, 04:12:38 am »
Yes I think you right definitely looks to be the issue I am hitting. That means running the server on Debian 13 it can never be fixed until maybe Debian 14 if OpenSSL 4 is part of it.
I did try TaurusTLS but without your fixes/improvements, I will try it again and see if their patch will get me out of trouble.

Edit : Tested with TaurusTLS and it does indeed crash with a GPF 13. This is a diffrent result to IndySec, I really hope there is a work around.

I think that Linux crash may be related to: https://github.com/IndySockets/Indy/issues/682

TaurusTLS made a pacth but the full solution is made with last Indy commit.
From what I understand, this change is actually a workaround for a standard OpenSSL behavior, which is what causes the problem.
OpenSSL version 4 does not have this behavior.
« Last Edit: July 07, 2026, 04:38:58 am by TheMouseAUS »

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #38 on: July 07, 2026, 09:03:27 am »
That means running the server on Debian 13 it can never be fixed until maybe Debian 14 if OpenSSL 4 is part of it.
I think you can use the experimental Debian branch to install version 4 of OpenSSL, something like this (after added the experimental list of repo):

Code: Pascal  [Select][+][-]
  1. sudo apt install -t experimental libssl4

Or more simply copy files from here: https://packages.debian.org/experimental/libssl4
Quote
File list of package libssl4 in experimental of architecture amd64

/usr/lib/x86_64-linux-gnu/libcrypto.so.4
/usr/lib/x86_64-linux-gnu/libssl.so.4
/usr/share/doc/libssl4/changelog.Debian.gz
/usr/share/doc/libssl4/changelog.gz
/usr/share/doc/libssl4/copyright
« Last Edit: July 07, 2026, 09:26:32 am by LeP »
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

TheMouseAUS

  • Full Member
  • ***
  • Posts: 136
Re: Need help with Indy IdTCPServer
« Reply #39 on: July 08, 2026, 08:01:41 am »
The guys over at TaurusTLS have fixed it for me https://github.com/TaurusTLS-Developers/TaurusTLS/issues/240, I compiled it and it fixes my issue!

Thanks to every one :-)

LeP

  • Sr. Member
  • ****
  • Posts: 426
Re: Need help with Indy IdTCPServer
« Reply #40 on: July 08, 2026, 09:24:13 am »
Very good, I'm happy that is resolved in Lazarus/FPC too.
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

 

TinyPortal © 2005-2018