-
Notifications
You must be signed in to change notification settings - Fork 57
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
Unloading of plctag.dll stuck in Shutdown #347
Comments
Hi @Teldaril - thanks for the message, and welcome to the libplctag community. Is it a problem that you need to call Shutdown when exiting the program? Please note that you need to dispose of the tag before calling Shutdown. P.S. do the remarks in the documentation comments correlate with what you're seeing? |
Thanks for the fast answer!
|
The After closing the last tag, calling I do not have a running Windows 7 VM anymore so duplicating your results may be challenging :-( |
If one of the threads is hanging, that might explain why the wake call is not working. Windows is a little more challenging to figure out as the wake model does not fit it quite as well as POSIX-based OSes like Linux and macOS. Thanks for the debugging output. SPEW (named appropriately) really does dump nearly everything that goes on, so maybe there is a hint somewhere in there. Can you attach a full log of the output? |
Hello, i have logs for 8 scenarios:
On Win10:
On Win10:
On Win10:
On Win10: Additionally the only thread left when unloading and stuck on Win7 is the main thread with the stack trace shown in my initial post. For me it looks like the tag_tickler_func thread is killed before the shutdown wants to handle this thread and the WakeConditionVariable in the shutdown is stuck for some reason. |
Hi @Teldaril - some changes have been made to the core library which may improve this situation. These recent versions have been included in the libplctag.NET packages published today. |
Hello,
i have a problem with the shutdown of the library. Probably it is more related to the c-library than to the c#-wrapper. But currently i am working with the wrapper. Here is a sample to reproduce the behavior:
The problem happens when i rely on the shutdown when the plctag.dll is unloaded after leaving the Program.cs. On Windows 7 i can get a stuck process blocking the plctag.dll from further usage. (e.g. restarting the given sample)
When running the sample on Windows 7 and Windows 10 with the preemptive Shutdown() uncommented the log looks like this:
The tag_tickler_func thread is signaled by cond_signal_impl and received by cond_wait_impl. The tag_tickler_func thread correctly terminates -> 2023-07-18 09:25:15.059 thread(2) tag(0) INFO tag_tickler_func:646 Terminating.
When running the sample on Windows 10 with the preemtive Shutdown() commented it looks like this:
The tag_tickler_func thread is signaled by cond_signal_impl but never responds in the log. No cond_wait_impl call and no termination. As if the thread is already gone. But Windows 10 just moves past cond_signal_impl and tears down the library.
When running the sample on Windows 7 with the preemtive Shutdown() commented it looks like this:
The tag_tickler_func thread is signaled by cond_signal_impl but never responds in the log. But there the main thread is stuck.
I tried to analyze this with Process Explorer and got a single remaining thread stuck with a call stack:
My workaround is to preemtively call Shutdown().
The text was updated successfully, but these errors were encountered: