Opened 10 years ago

Last modified 10 years ago

#8243 new Bugs

strerror is not thread-safe on all platforms

Reported by: Andrey Semashev Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

boost/exception/errinfo_errno.hpp uses strerror function which is not thread-safe on many platforms (e.g. Linux). Its use should be replaced with strerror_r, when possible.

As a hint for implementation see libs/system/src/error_code.cpp.

Change History (5)

comment:1 by Emil Dotchevski, 10 years ago

Perhaps this should be implemented as a module that can be called from errinfo_errno.hpp? Note however that in this case it has to be header-only module because Boost Exception can't require separate build.

comment:2 by Andrey Semashev, 10 years ago

Yes, that's probably a good idea (I created several tickets like this one for different libraries). However, it's not clear which library should host this tool.

I had the idea of creating a BOOST_HAS_STRERROR_R macro in Boost.Config, which would simplify the detection of strerror_r. The strerror_r use is rather simple and I'm not sure there's need to extract the call itself.

comment:3 by Emil Dotchevski, 10 years ago

Can't we have boost/strerror.hpp that defines boost::strerror() which either uses strerror_r or falls back to whatever other behavior makes sense? I don't think it's worth involving Boost.Config or any other library in this.

comment:4 by Andrey Semashev, 10 years ago

With the upcoming move to modularized Boost, I don't think that top level headers will be welcome. Maybe boost/utility/strerror.hpp or boost/system/strerror.hpp? Maybe we should bring this up on the ML?

comment:5 by Emil Dotchevski, 10 years ago

Where strerror.hpp is doesn't make it less or more modular, assuming it does not depend on other Boost headers, which it shouldn't. If it is put in "utility" someone might reasonably think that it's part of the entire "utility" lib, which would be the opposite of modular design. My 2c anyway.

Note: See TracTickets for help on using tickets.