8148425: strerror() function is not thread-safe

Reviewed-by: dholmes, coleenp
This commit is contained in:
Thomas Stuefe 2016-03-12 08:35:05 +01:00
parent 69e1552338
commit 3487b38cc4
22 changed files with 300 additions and 137 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "runtime/os.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/threadCritical.hpp"
@ -49,7 +50,7 @@ ThreadCritical::ThreadCritical() {
if (global_mut_owner != owner) {
if (os::Solaris::mutex_lock(&global_mut))
fatal("ThreadCritical::ThreadCritical: mutex_lock failed (%s)",
strerror(errno));
os::strerror(errno));
assert(global_mut_count == 0, "must have clean count");
assert(global_mut_owner == -1, "must have clean owner");
}
@ -68,7 +69,7 @@ ThreadCritical::~ThreadCritical() {
if (global_mut_count == 0) {
global_mut_owner = -1;
if (os::Solaris::mutex_unlock(&global_mut))
fatal("ThreadCritical::~ThreadCritical: mutex_unlock failed (%s)", strerror(errno));
fatal("ThreadCritical::~ThreadCritical: mutex_unlock failed (%s)", os::strerror(errno));
}
} else {
assert (Threads::number_of_threads() == 0, "valid only during initialization");