提交 c3c99cd2 编写于 作者: C ccheung

8006001: [parfait] Possible file leak in hotspot/src/os/linux/vm/perfMemory_linux.cpp

Reviewed-by: zgu, coleenp, hseigel, dholmes
上级 84213d5a
...@@ -672,15 +672,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) { ...@@ -672,15 +672,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
RESTARTABLE(::open(filename, oflags), result); RESTARTABLE(::open(filename, oflags), result);
if (result == OS_ERR) { if (result == OS_ERR) {
if (errno == ENOENT) { if (errno == ENOENT) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Process not found"); "Process not found", OS_ERR);
} }
else if (errno == EACCES) { else if (errno == EACCES) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Permission denied"); "Permission denied", OS_ERR);
} }
else { else {
THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno)); THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
} }
} }
...@@ -828,7 +828,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -828,7 +828,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
char* mapAddress; char* mapAddress;
int result; int result;
int fd; int fd;
size_t size; size_t size = 0;
const char* luser = NULL; const char* luser = NULL;
int mmap_prot; int mmap_prot;
...@@ -899,9 +899,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -899,9 +899,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
if (*sizep == 0) { if (*sizep == 0) {
size = sharedmem_filesize(fd, CHECK); size = sharedmem_filesize(fd, CHECK);
assert(size != 0, "unexpected size"); } else {
size = *sizep;
} }
assert(size > 0, "unexpected size <= 0");
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
// attempt to close the file - restart if it gets interrupted, // attempt to close the file - restart if it gets interrupted,
......
...@@ -672,15 +672,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) { ...@@ -672,15 +672,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
RESTARTABLE(::open(filename, oflags), result); RESTARTABLE(::open(filename, oflags), result);
if (result == OS_ERR) { if (result == OS_ERR) {
if (errno == ENOENT) { if (errno == ENOENT) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Process not found"); "Process not found", OS_ERR);
} }
else if (errno == EACCES) { else if (errno == EACCES) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Permission denied"); "Permission denied", OS_ERR);
} }
else { else {
THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno)); THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
} }
} }
...@@ -828,7 +828,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -828,7 +828,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
char* mapAddress; char* mapAddress;
int result; int result;
int fd; int fd;
size_t size; size_t size = 0;
const char* luser = NULL; const char* luser = NULL;
int mmap_prot; int mmap_prot;
...@@ -899,9 +899,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -899,9 +899,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
if (*sizep == 0) { if (*sizep == 0) {
size = sharedmem_filesize(fd, CHECK); size = sharedmem_filesize(fd, CHECK);
assert(size != 0, "unexpected size"); } else {
size = *sizep;
} }
assert(size > 0, "unexpected size <= 0");
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
// attempt to close the file - restart if it gets interrupted, // attempt to close the file - restart if it gets interrupted,
......
...@@ -687,15 +687,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) { ...@@ -687,15 +687,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
RESTARTABLE(::open(filename, oflags), result); RESTARTABLE(::open(filename, oflags), result);
if (result == OS_ERR) { if (result == OS_ERR) {
if (errno == ENOENT) { if (errno == ENOENT) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Process not found"); "Process not found", OS_ERR);
} }
else if (errno == EACCES) { else if (errno == EACCES) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
"Permission denied"); "Permission denied", OS_ERR);
} }
else { else {
THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno)); THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
} }
} }
...@@ -843,7 +843,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -843,7 +843,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
char* mapAddress; char* mapAddress;
int result; int result;
int fd; int fd;
size_t size; size_t size = 0;
const char* luser = NULL; const char* luser = NULL;
int mmap_prot; int mmap_prot;
...@@ -914,9 +914,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor ...@@ -914,9 +914,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
if (*sizep == 0) { if (*sizep == 0) {
size = sharedmem_filesize(fd, CHECK); size = sharedmem_filesize(fd, CHECK);
assert(size != 0, "unexpected size"); } else {
size = *sizep;
} }
assert(size > 0, "unexpected size <= 0");
mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
// attempt to close the file - restart if it gets interrupted, // attempt to close the file - restart if it gets interrupted,
......
...@@ -1581,7 +1581,7 @@ static void open_file_mapping(const char* user, int vmid, ...@@ -1581,7 +1581,7 @@ static void open_file_mapping(const char* user, int vmid,
ResourceMark rm; ResourceMark rm;
void *mapAddress = 0; void *mapAddress = 0;
size_t size; size_t size = 0;
HANDLE fmh; HANDLE fmh;
DWORD ofm_access; DWORD ofm_access;
DWORD mv_access; DWORD mv_access;
...@@ -1652,9 +1652,12 @@ static void open_file_mapping(const char* user, int vmid, ...@@ -1652,9 +1652,12 @@ static void open_file_mapping(const char* user, int vmid,
if (*sizep == 0) { if (*sizep == 0) {
size = sharedmem_filesize(rfilename, CHECK); size = sharedmem_filesize(rfilename, CHECK);
assert(size != 0, "unexpected size"); } else {
size = *sizep;
} }
assert(size > 0, "unexpected size <= 0");
// Open the file mapping object with the given name // Open the file mapping object with the given name
fmh = open_sharedmem_object(robjectname, ofm_access, CHECK); fmh = open_sharedmem_object(robjectname, ofm_access, CHECK);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册