[PATCH] D20903: Make system_error::message() thread safe. Fixes PR25598.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 19:43:16 PDT 2016
EricWF added a comment.
In http://reviews.llvm.org/D20903#446922, @mclow.lists wrote:
> In general, I'm OK with this - but I'm concerned about that there's not really any provision for the case where `strerror_r` does not exist.
>
> Also, there's no reason to have a thread local static array here, if you're going to immediately copy it into a `std::string`.
Ack. I changed the arrays to be neither static nor thread_local.
In http://reviews.llvm.org/D20903#447650, @erik65536 wrote:
> The C++ spec states that `error_category::message()` shall not change the value of `errno` (See section 19.5). So `errno` will have to be saved and restored if `strerror_r()` fails.
Good catch. I only have to do this for the POSIX version. I'll make the change.
> The POSIX version of `strerror_r()` returns 0 on success, and any other value indicates an error (Reference <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html>).
>
> The function may return uninitialized memory if `std::snprintf()` fails.
I don't see how snprintf could possible fail.
> You may want to a version for Windows that calls `strerror_s()`.
Libc++ provides no windows support.
http://reviews.llvm.org/D20903
More information about the cfe-commits
mailing list