FNC Grid cause suddenly EOSError 1400

I swapped the VCL AdvGrid with the FNC grid, and many people (not all, I also dont get this and cant reproduce it) who run our program are getting exceptions "EOSError System Error. Code: 1400. Invalid window handle".

Below a part of the stack trace.

004909cd +00d scrapebox.exe System.SysUtils RaiseLastOSError
00686a76 +056 scrapebox.exe Vcl.Controls TWinControl.DestroyWindowHandle
00686a0a +06a scrapebox.exe Vcl.Controls TWinControl.DestroyWnd
00686dc9 +099 scrapebox.exe Vcl.Controls TWinControl.DestroyHandle
00685d97 +057 scrapebox.exe Vcl.Controls TWinControl.RemoveControl
0067f077 +047 scrapebox.exe Vcl.Controls TControl.SetParent
0068ffb6 +056 scrapebox.exe Vcl.Controls TWinControl.SetParent
014fc691 +361 scrapebox.exe VCL.TMSFNCCustomScrollControl 1104 +46 TTMSFNCCustomScrollControl.UpdateControlScrollBars
016928de +16e scrapebox.exe VCL.TMSFNCCustomGrid 7265 +32 TTMSFNCCustomGrid.UpdateControlCache
014fbc1f +00f scrapebox.exe VCL.TMSFNCCustomScrollControl 749 +1 TTMSFNCCustomScrollControl.UpdateControl
014fbfee +02e scrapebox.exe VCL.TMSFNCCustomScrollControl 916 +4 TTMSFNCCustomScrollControl.EndUpdate
01686feb +00b scrapebox.exe VCL.TMSFNCCustomGrid 3882 +1 TTMSFNCCustomGrid.EndUpdate
01522f34 +154 scrapebox.exe VCL.TMSFNCGridData 9675 +28 TTMSFNCGridData.SetRowCount

The error seems to point to the use of threads. Are you using threads and if so, are you correctly accessing/refreshing GUI elements with a synchronize?

I also thought about that, but I do not access any gui element from a thread. If ever the grid need to be modified, I do that in an timer event, not within a thread. I also cannot reproduce this error on any of my PC's, but getting more and more reports from user since the vcl grid was swapped with the fnc grid.

Unfortunately, without more details, it's unclear how we can reproduce this here. Is the application running on a virtual machine?

No, but running on various Windows VPS (Win 10, Server 2008, Server 2012).
Anyway, I will try to get more details.

I am getting more and more reports causing this EOSError since I switched the grid from the vcl grid to the fnc grid.

Most of the time, its related to TTMSFNCCustomScrollControl.Destroy
There is a grid on the form, and when that form close, it´cause the exceptions.

0049094d +00d scrapebox.exe System.SysUtils RaiseLastOSError
00686df6 +056 scrapebox.exe Vcl.Controls TWinControl.DestroyWindowHandle
006841fe +0ce scrapebox.exe Vcl.Controls TWinControl.Destroy
0040e9c5 +015 scrapebox.exe System TObject.Free
014fbe86 +036 scrapebox.exe VCL.TMSFNCCustomScrollControl 408 +3 TTMSFNCCustomScrollControl.Destroy
0151a06c +11c scrapebox.exe VCL.TMSFNCGridData 2326 +22 TTMSFNCGridData.Destroy
016813f2 +1e2 scrapebox.exe VCL.TMSFNCCustomGrid 2003 +33 TTMSFNCCustomGrid.Destroy

Here is the part of your code where it keeps on crashing:

014f4730 public VCL.TMSFNCCustomScrollControl.TTMSFNCCustomScrollControl.Destroy: ; function entry point
014f4730 405 push rsi
014f4731 push rbx
014f4732 sub rsp, $28
014f4736 mov rbx, rcx
014f4739 mov esi, edx
014f473c mov rcx, rbx
014f473f mov edx, esi
014f4742 call -$10e5467 ($40f2e0) ; System.@BeforeDestruction
014f4747 406 mov rcx, [rbx+$6f8]
014f474e call -$10e5f13 ($40e840) ; System.TObject.Free
014f4753 407 mov rcx, [rbx+$700]
014f475a call -$10e5f1f ($40e840) ; System.TObject.Free
014f475f 408 mov rcx, [rbx+$6e8]
014f4766 > call -$10e5f2b ($40e840) ; System.TObject.Free // *** HERE IS THE CRASH WITH EOSERROR 1400
014f476b 409 mov rcx, [rbx+$6f0]
014f4772 call -$10e5f37 ($40e840) ; System.TObject.Free
014f4777 410 mov rcx, rbx
014f477a mov edx, esi
014f477d and dl, -4
014f4780 call -$d195 ($14e75f0) ; VCL.TMSFNCCustomControl.TTMSFNCCustomControl.Destroy
014f4785 411 test dh, sil
014f4788 jle loc_14f4792
014f478a mov rcx, rbx
014f478d call -$10e5532 ($40f260) ; System.@ClassDestroy
014f4792 add rsp, $28
014f4796 pop rbx
014f4797 pop rsi
014f4798 ret


Can you destroy the grid manually, in the form close query event? Before the actual destruction of the form, and see if that fixes the crash?