Skip to content

Pipe is not thread-safe #5161

@aleks-f

Description

@aleks-f

Pipe FDs are not atomic and there is no thread protection, causing races and exceptions that propagate to PollSet destructor on BSD/Mac (Linux uses epoll for internal notification) in a busy concurrent situations:

Write of size 8 at 0x0001081020e0 by main thread:
6:     #0 Poco::Net::PollSetImpl::~PollSetImpl() PollSet.cpp:359 (libPocoNet.112.dylib:arm64+0x985b8)
6:     #1 Poco::Net::PollSet::~PollSet() PollSet.cpp:694 (libPocoNet.112.dylib:arm64+0x96ad8)
6:     #2 Poco::Net::SocketReactor::~SocketReactor() SocketReactor.cpp:67 (libPocoNet.112.dylib:arm64+0xca0a4)
6:     #3 Poco::Net::SocketReactor::~SocketReactor() SocketReactor.cpp:67 (libPocoNet.112.dylib:arm64+0xca0f4)
6:     #4 SocketReactorTest::testConcurrentHandlerRemoval() SocketReactorTest.cpp:895 (Net-testrunner:arm64+0x1001310f8)

As a minimum, FDs need to be atomic and an atomic flag should be added to Pipe and PollSet to sync pipe io/close.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions