-
Notifications
You must be signed in to change notification settings - Fork 262
Threads in VST #1245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What exactly make you think that the thread of Virtual TreeView causes the crash? |
I attach demo code (two projects: exe and dll): On my computer have no errors, but when I run it on Windows 2012/2016/2019 Server, click button and close window (by shortcut, by mouse click - no matter) in 1 on 10 times crash (but sometime can be 10 times without error, and next every 3 run and close ends with crash). |
PS - When I made changes in dispose method, then works good: class procedure TWorkerThread.Dispose(CanBlock: Boolean);
var
LRef: TThread;
begin
WorkerThread.FreeOnTerminate := False; // << NEVR USE FREE ON TERMINATE
//WorkerThread.FreeOnTerminate := not CanBlock; // << -- " --
WorkerThread.Terminate();
SetEvent(WorkerThread.FWorkEvent);
LRef := WorkerThread;
WorkerThread.WaitFor; // << ADD WAITING FOR TERMINATE
WorkerThread := nil; //Will be freed usinf TThread.FreeOnTerminate
//if CanBlock then << DISABLE THIS LINE - OBJECT MUST BE ALWAYS FREE
LRef.Free;
end; |
I didn't get a single crash in 30 tries with your demo project. Can you please check if the following change makes any difference in your case: In
|
I try my demo on my own system, and it's crash after about 1 on 60-80 trials (very infrequently, but possible). I think, it depends on cpu cores load. I made the changes as suggested (and I rolled back my own previous changes) and looks all right - no more crashes. |
I have very hard problem - in some case, when I have window with VST in DLL, and I close it, whole application sometimes crash with AV error in unloaded DLL (especially on slow computers).
If I add sleep (f.ex. 500 ms) after window free, but before end of DLL's procedure (witch open and free my form with VST), then looks work good.
So, I think it can be some mistake in some thread... But where?
I look on
VirtualTrees.WorkerThread
file andDispose
procedure and have question: why is there terminate and setevent, but not waiting for really terminate thread (WaitFor
)? But I'm not sure this applies to my case or this is true mistake.It's applies to 7.x and 8.0 version.
The text was updated successfully, but these errors were encountered: