comparison src/os/linux/vm/perfMemory_linux.cpp @ 9064:4b7cf00ccb08

8006001: [parfait] Possible file leak in hotspot/src/os/linux/vm/perfMemory_linux.cpp Reviewed-by: zgu, coleenp, hseigel, dholmes
author ccheung
date Fri, 05 Apr 2013 11:15:13 -0700
parents 716c64bda5ba
children a837fa3d3f86
comparison
equal deleted inserted replaced
9060:cc32ccaaf47f 9064:4b7cf00ccb08
670 // open the file 670 // open the file
671 int result; 671 int result;
672 RESTARTABLE(::open(filename, oflags), result); 672 RESTARTABLE(::open(filename, oflags), result);
673 if (result == OS_ERR) { 673 if (result == OS_ERR) {
674 if (errno == ENOENT) { 674 if (errno == ENOENT) {
675 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 675 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
676 "Process not found"); 676 "Process not found", OS_ERR);
677 } 677 }
678 else if (errno == EACCES) { 678 else if (errno == EACCES) {
679 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 679 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
680 "Permission denied"); 680 "Permission denied", OS_ERR);
681 } 681 }
682 else { 682 else {
683 THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno)); 683 THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
684 } 684 }
685 } 685 }
686 686
687 return result; 687 return result;
688 } 688 }
826 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) { 826 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
827 827
828 char* mapAddress; 828 char* mapAddress;
829 int result; 829 int result;
830 int fd; 830 int fd;
831 size_t size; 831 size_t size = 0;
832 const char* luser = NULL; 832 const char* luser = NULL;
833 833
834 int mmap_prot; 834 int mmap_prot;
835 int file_flags; 835 int file_flags;
836 836
897 fd = open_sharedmem_file(rfilename, file_flags, CHECK); 897 fd = open_sharedmem_file(rfilename, file_flags, CHECK);
898 assert(fd != OS_ERR, "unexpected value"); 898 assert(fd != OS_ERR, "unexpected value");
899 899
900 if (*sizep == 0) { 900 if (*sizep == 0) {
901 size = sharedmem_filesize(fd, CHECK); 901 size = sharedmem_filesize(fd, CHECK);
902 assert(size != 0, "unexpected size"); 902 } else {
903 } 903 size = *sizep;
904 }
905
906 assert(size > 0, "unexpected size <= 0");
904 907
905 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); 908 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
906 909
907 // attempt to close the file - restart if it gets interrupted, 910 // attempt to close the file - restart if it gets interrupted,
908 // but ignore other failures 911 // but ignore other failures