RFR(s): 8148425: strerror() function is not thread-safe

David Holmes david.holmes at oracle.com
Mon Feb 29 03:44:56 UTC 2016


Hi Thomas,

On 27/02/2016 2:05 AM, Thomas Stüfe wrote:
> Hi,
>
> please take a look at this proposed fix:
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8148425
> Webrev:
> http://cr.openjdk.java.net/~stuefe/webrevs/8141425-strerror-replacement/webrev.00/webrev/
>
> This adds a replacement function os::strerror() as a drop-in for
> strerror(), which has a number of issues.
>
> strerror() is unsafe to use and may cause (and has caused) crashes in
> multithreaded scenarios. It is also not ideal for log files because of the
> implicit localization of the error messages.
>
> For details please see the discussion under the bug report.

I just came across strerror_l, which is required to be thread-safe. Is 
that a possible alternative? (I'm not sure how locale's are obtained).

Otherwise what you have seems okay - though I do dislike having to 
duplicate all that details already buried in the system headers/library. 
Not sure we need to the long text at the VM level - which would simplify 
things a bit.

Thanks,
David

> Please note that I did not yet change any call sites, although all call
> sites in the os namespace should already use the new function. I wanted to
> see whether there would be any general objections.
>
> Kind Regards, Thomas
>


More information about the hotspot-runtime-dev mailing list