[fpc-pascal] Stuck in TMSSQLConnection.Execute

michael michael at freepascal.org
Wed May 6 12:02:33 CEST 2026


Are you using 1 connection per thread ? If not, then that may be your 
problem.

Michael.

On 2026-05-06 10:55, Luca Olivetti via fpc-pascal wrote:
> Hello,
> 
> I encountered a strange problem in an application, that's been running 
> for over a year now.
> The application is quite convoluted with hundred of threads, one 
> (actually more than one) of those threads connects to an ms sql server 
> and now it blocks inside TMSSQLConnection.Execute, but not always
> 
> 
> procedure TMSSQLConnection.Execute(const cmd: string);
> begin
>   DBErrorStr:='';
>   DBMsgStr  :='';
>   CheckError( dbcmd(FDBProc, PAnsiChar(cmd)) );
>   CheckError( dbsqlexec(FDBProc) );  <--- this doesn't return
>   CheckError( dbresults(FDBProc) );
> end;
> 
> 
> However when I terminate the application and before the destroy method 
> of the thread is called, dbsqlexec returns and the rest of the thread 
> goes on as nothing happened.
> 
> As an experiment I wrapped the method in synchronize but that only 
> freezes the gui when it happens.
> 
> I don't know it if is relevant but I have a note in my program that I 
> have to initialize the sql server libraries in the main thread, 
> otherwise doing it in another thread eventually causes a sigsev.
> 
> I got the dlls (almost 2 years ago) following the instructions here
> 
> https://forum.lazarus.freepascal.org/index.php/topic,55037.msg409167.html#msg409167
> 
> using Environment: PLAT=Win32, WIDTH=32, VS_VERSION=2017, TDSVER=7.3
> (though older artifacts are deleted after a month)
> 
> This is on windows 32 bits, fpc 3.2.2, any hint on how to debug it 
> further?
> 
> Bye


More information about the fpc-pascal mailing list