7017009: Secondary out of c-heap memory error reporting out of memory

Thu, 03 Feb 2011 21:30:08 -0500

author
coleenp
date
Thu, 03 Feb 2011 21:30:08 -0500
changeset 2512
d28def44457d
parent 2510
face83fc8882
child 2513
5e139f767ddb

7017009: Secondary out of c-heap memory error reporting out of memory
Summary: Use os::malloc() to allocate buffer to read elf symbols and check for null
Reviewed-by: zgu, phh, dsamersoff, dholmes, dcubed

src/share/vm/utilities/elfSymbolTable.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/utilities/elfSymbolTable.cpp	Wed Feb 02 18:38:40 2011 -0500
     1.2 +++ b/src/share/vm/utilities/elfSymbolTable.cpp	Thu Feb 03 21:30:08 2011 -0500
     1.3 @@ -39,13 +39,14 @@
     1.4    // try to load the string table
     1.5    long cur_offset = ftell(file);
     1.6    if (cur_offset != -1) {
     1.7 -    m_symbols = (Elf_Sym*)NEW_C_HEAP_ARRAY(char, shdr.sh_size);
     1.8 +    // call malloc so we can back up if memory allocation fails.
     1.9 +    m_symbols = (Elf_Sym*)os::malloc(shdr.sh_size);
    1.10      if (m_symbols) {
    1.11        if (fseek(file, shdr.sh_offset, SEEK_SET) ||
    1.12          fread((void*)m_symbols, shdr.sh_size, 1, file) != 1 ||
    1.13          fseek(file, cur_offset, SEEK_SET)) {
    1.14          m_status = Decoder::file_invalid;
    1.15 -        FREE_C_HEAP_ARRAY(char, m_symbols);
    1.16 +        os::free(m_symbols);
    1.17          m_symbols = NULL;
    1.18        }
    1.19      }
    1.20 @@ -59,7 +60,7 @@
    1.21  
    1.22  ElfSymbolTable::~ElfSymbolTable() {
    1.23    if (m_symbols != NULL) {
    1.24 -    FREE_C_HEAP_ARRAY(char, m_symbols);
    1.25 +    os::free(m_symbols);
    1.26    }
    1.27  
    1.28    if (m_next != NULL) {

mercurial