poco/Net
sebastien-guay a9982e68ba "SocketReactor::addEventHandler" and "SocketReactor::removeEventHandler" must protect the access to "NotifierPtr pNotifier" (#1709)
Those two methods already use FastMutex::ScopedLock lock(_mutex), but
the scope is not large enough to protect "NotifierPtr pNotifier" that is
accessed by calling SocketNotifier::addObserver() and
SocketNotifier::removeObserver().

It is mentioned in SocketReator.h that it is safe to call
addEventHandler() and removeEventHandler() from another thread while the
SocketReactor is running. My current use of the SocketReactor
encountered an issue where the SocketNotifier::_events has been
corrupted by a concurent write access done by
SocketReactor::addEventHandler() and
SocketReactor::removeEventHandler().
The call stack show that the SocketReactor::addEventHandler is stuck in
a while loop in gcc/libstdc++/tree.cc Rb_tree_insert_and_rebalance()

I clearly see in my logs that it happened while my
SocketConnector::unregisterConnector() and
SocketConnector::registerConnector() were called by two different
threads.

#0 0x00a80a7b in std::_Rb_tree_insert_and_rebalance () from
/usr/lib/libstdc++.so.6
#1 0x06ccb430 in std::_Rb_tree<Poco::Net::SocketNotification*,
Poco::Net::SocketNotification*,
std::_IdentityPoco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::_M_insert
(this=0xac75dc90, __x=0x0, __p=0xac7ed0c8, __v=@0xb5fb0c40) at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_tree.h:816
#2 0x06ccb15d in std::_Rb_tree<Poco::Net::SocketNotification*,
Poco::Net::SocketNotification*,
std::_IdentityPoco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::insert_equal
(this=0xac75dc90, __v=@0xb5fb0c40) at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_tree.h:858
#3 0x06ccad86 in std::multiset<Poco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::insert (this=0xac75dc90,
__x=@0xb5fb0c40)
at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_multiset.h:306
#4 0x06cca72b in Poco::Net::SocketNotifier::addObserver
(this=0xac75dc70, pReactor=0x8d27958, observer=@0xb5fb0cd0) at
src/SocketNotifier.cpp:45
#5 0x06cd060f in Poco::Net::SocketReactor::addEventHandler
(this=0x8d27958, socket=@0xac7f5a74, observer=@0xb5fb0cd0) at
src/SocketReactor.cpp:178

SocketReactor::run() is already protecting the access to the
SocketNotifier.
2017-08-10 10:10:09 +02:00
..
cmake Do not overwrite CMAKE_PREFIX_PATH in component config files. 2015-02-04 04:35:23 +01:00
include/Poco/Net Fix VisualStudio warning C4245 in NetworkInterface.h (#1823) 2017-07-23 21:09:57 +02:00
samples Fix typos in comments, documentation and strings (#1615) 2017-07-06 00:17:38 +02:00
src "SocketReactor::addEventHandler" and "SocketReactor::removeEventHandler" must protect the access to "NotifierPtr pNotifier" (#1709) 2017-08-10 10:10:09 +02:00
testsuite added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
CMakeLists.txt Add testsuite directory instead of samples when ENABLE_TESTS 2015-12-19 18:03:56 +01:00
dependencies new trunk (base for 1.5) 2012-04-23 01:14:34 +00:00
Makefile added OAuth20Credentials class, some minor OAuth10Credentials fixes 2014-11-11 12:10:53 +01:00
Net_CE_vs90.sln new trunk (base for 1.5) 2012-04-23 01:14:34 +00:00
Net_CE_vs90.vcproj updated project files 2014-11-11 12:19:14 +01:00
Net_vs90.sln change EOL to 'native' 2012-04-29 18:52:25 +00:00
Net_vs90.vcproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs100.sln added SMTPChannel to Net project file 2012-10-14 19:28:02 +00:00
Net_vs100.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs100.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs110.sln the great line endings cleanup 2012-11-11 09:57:01 +01:00
Net_vs110.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs110.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs120.sln re-generated vs100-vs120 project files 2014-04-21 10:50:51 +02:00
Net_vs120.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs120.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_vs140.sln added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_vs140.vcxproj added Visual Studio 2015 project files 2015-07-30 15:48:45 +02:00
Net_vs140.vcxproj.filters added Visual Studio 2015 project files 2015-07-30 15:48:45 +02:00
Net_vs150.sln added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_vs150.vcxproj added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_vs150.vcxproj.filters added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_WEC2013_vs110.sln fixed WEC2013 project files 2014-05-27 23:00:54 +02:00
Net_WEC2013_vs110.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_WEC2013_vs110.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_WEC2013_vs120.sln added VS2013 project/solution files for Windows Embedded Compact 2013 2014-08-09 10:49:04 +02:00
Net_WEC2013_vs120.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_WEC2013_vs120.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs90.sln new trunk (base for 1.5) 2012-04-23 01:14:34 +00:00
Net_x64_vs90.vcproj updated project files 2014-11-11 12:19:14 +01:00
Net_x64_vs100.sln new trunk (base for 1.5) 2012-04-23 01:14:34 +00:00
Net_x64_vs100.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs100.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs110.sln the great line endings cleanup 2012-11-11 09:57:01 +01:00
Net_x64_vs110.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs110.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs120.sln re-generated vs100-vs120 project files 2014-04-21 10:50:51 +02:00
Net_x64_vs120.vcxproj fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs120.vcxproj.filters fixed GH #471: vs2010 release builds have optimization disabled 2014-11-20 21:22:52 +01:00
Net_x64_vs140.sln added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_x64_vs140.vcxproj added Visual Studio 2015 project files 2015-07-30 15:48:45 +02:00
Net_x64_vs140.vcxproj.filters added Visual Studio 2015 project files 2015-07-30 15:48:45 +02:00
Net_x64_vs150.sln added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_x64_vs150.vcxproj added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net_x64_vs150.vcxproj.filters added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Net.progen change EOL to 'native' 2012-04-29 18:52:25 +00:00
Net.vxbuild new trunk (base for 1.5) 2012-04-23 01:14:34 +00:00