-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Crash due to race condition in TCPServerDispatcher #2085
Comments
Possibly fixed with #1965 |
I don't think that #1965 fixes this issue. It seems like it would still be possible to enqueue the TCPServerDispatcher and there is nothing to prevent it from getting destructed before the thread starts running it. It seems like there is an attempt to keep the Runnable object alive by adding a self reference inside the run() method (guard local), but that would only work once the run method starts executing. It's still possible to destruct it before the thread starts executing run(). |
After thinking this through, I don't think there's an easy solution. It would be possible to call |
why is this stil opened? i thought it was fixed (as much as it can be) with this |
I don't know. |
Expected behavior
Clean server shutdown with no crash.
Actual behavior
#0 0x00007fc7d030a0c1 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007fc7c0da4ed1 in ?? () from .so
#2
#3 0x0000000009078380 in ?? ()
#4 0x00007fc7c2ff429f in Poco::PooledThread::run() () from bin/glnxa64/libPocoFoundation.so.48
#5 0x00007fc7c2feff86 in Poco::ThreadImpl::runnableEntry(void*) () from bin/glnxa64/libPocoFoundation.so.48
#6 0x00007fc7d0305064 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#7 0x00007fc7d1ba462d in clone () from /lib/x86_64-linux-gnu/libc.so.6
Steps to reproduce the problem
This is a very rare issue that has been causing sporadic crashes in our build and test environment. I believe the issue is reproducible when there is a server.stop() call concurrent with a new socket connection.
I believe the problem is that a new socket connection enqueues the TCPServerDispatcher instance without changing the reference count. That means that if you shutdown the server before the TCPServerDispatcher::run method starts the ref count would go to zero before the AutoPtr in run() has a chance to increment the ref count.
I think that incrementing the ref count before enqueuing TCPServerDispatcher (and decrementing at the end of run()) would resolve the issue and ensure that the run() method can be safely called during server shutdown.
POCO version
1.7.9
Compiler and version
gcc 6.3.0-GLIBC2.11
Operating system and version
debian 8
Other relevant information
The text was updated successfully, but these errors were encountered: