src/os/linux/vm/perfMemory_linux.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot.open Sdiff src/os/linux/vm

src/os/linux/vm/perfMemory_linux.cpp

Print this page
rev 1916 : 7007769: VM crashes with SIGBUS writing PerfData if tmp space is full
Summary: Fill perfdata file with zeros to verify available disk space
Reviewed-by: coleenp, kamg


 618   if (result == OS_ERR) {
 619     if (PrintMiscellaneous && Verbose) {
 620       warning("could not create file %s: %s\n", filename, strerror(errno));
 621     }
 622     return -1;
 623   }
 624 
 625   // save the file descriptor
 626   int fd = result;
 627 
 628   // set the file size
 629   RESTARTABLE(::ftruncate(fd, (off_t)size), result);
 630   if (result == OS_ERR) {
 631     if (PrintMiscellaneous && Verbose) {
 632       warning("could not set shared memory file size: %s\n", strerror(errno));
 633     }
 634     RESTARTABLE(::close(fd), result);
 635     return -1;
 636   }
 637 


















 638   return fd;




 639 }
 640 
 641 // open the shared memory file for the given user and vmid. returns
 642 // the file descriptor for the open file or -1 if the file could not
 643 // be opened.
 644 //
 645 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
 646 
 647   // open the file
 648   int result;
 649   RESTARTABLE(::open(filename, oflags), result);
 650   if (result == OS_ERR) {
 651     if (errno == ENOENT) {
 652       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 653                   "Process not found");
 654     }
 655     else if (errno == EACCES) {
 656       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 657                   "Permission denied");
 658     }




 618   if (result == OS_ERR) {
 619     if (PrintMiscellaneous && Verbose) {
 620       warning("could not create file %s: %s\n", filename, strerror(errno));
 621     }
 622     return -1;
 623   }
 624 
 625   // save the file descriptor
 626   int fd = result;
 627 
 628   // set the file size
 629   RESTARTABLE(::ftruncate(fd, (off_t)size), result);
 630   if (result == OS_ERR) {
 631     if (PrintMiscellaneous && Verbose) {
 632       warning("could not set shared memory file size: %s\n", strerror(errno));
 633     }
 634     RESTARTABLE(::close(fd), result);
 635     return -1;
 636   }
 637 
 638   // Verify that we have enough disk space for this file.
 639   // We'll get random SIGBUS crashes on memory accesses if
 640   // we don't.
 641 
 642   for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) {
 643     int zero_int = 0;
 644     result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos));
 645     if (result == -1 ) break;
 646     RESTARTABLE(::write(fd, &zero_int, 1), result);
 647     if (result != 1) {
 648       if (errno == ENOSPC) {
 649         warning("Insufficient space for shared memory file:\n   %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename);
 650       }
 651       break;
 652     }
 653   }
 654 
 655   if (result != -1) {
 656     return fd;
 657   } else {
 658     RESTARTABLE(::close(fd), result);
 659     return -1;
 660   }
 661 }
 662 
 663 // open the shared memory file for the given user and vmid. returns
 664 // the file descriptor for the open file or -1 if the file could not
 665 // be opened.
 666 //
 667 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
 668 
 669   // open the file
 670   int result;
 671   RESTARTABLE(::open(filename, oflags), result);
 672   if (result == OS_ERR) {
 673     if (errno == ENOENT) {
 674       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 675                   "Process not found");
 676     }
 677     else if (errno == EACCES) {
 678       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 679                   "Permission denied");
 680     }


src/os/linux/vm/perfMemory_linux.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File