# HG changeset patch # User bobv # Date 1292873424 18000 # Node ID 02895c6a2f82fd35cb2d4ca58aaf99297b1aa98c # Parent 6da3527317ff705b59e93a3e79199a6d2381fc70 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 diff -r 6da3527317ff -r 02895c6a2f82 src/os/linux/vm/perfMemory_linux.cpp --- a/src/os/linux/vm/perfMemory_linux.cpp Fri Dec 17 12:14:48 2010 +0000 +++ b/src/os/linux/vm/perfMemory_linux.cpp Mon Dec 20 14:30:24 2010 -0500 @@ -635,7 +635,29 @@ return -1; } - return fd; + // Verify that we have enough disk space for this file. + // We'll get random SIGBUS crashes on memory accesses if + // we don't. + + for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) { + int zero_int = 0; + result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos)); + if (result == -1 ) break; + RESTARTABLE(::write(fd, &zero_int, 1), result); + if (result != 1) { + if (errno == ENOSPC) { + warning("Insufficient space for shared memory file:\n %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename); + } + break; + } + } + + if (result != -1) { + return fd; + } else { + RESTARTABLE(::close(fd), result); + return -1; + } } // open the shared memory file for the given user and vmid. returns