JDK-8144491 : ElfSymbolTable::lookup returns bad value when the lookup has failed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-12-02
  • Updated: 2015-12-24
  • Resolved: 2015-12-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b99Fixed
Related Reports
Relates :  
Description
There's a bug in ElfSymbolTable::lookup - when it fails to find a symbol, it returns true (false should be returned).

bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable) {
....
  return true;  // <-- huh?
}

As a result the caller, ElfFile::decode, would be operating on an invalid string_table_index, which will cause m_status = NullDecoder::file_invalid, which will make all future calls to ElfFile::decode fail.

bool ElfFile::decode(address addr, char* buf, int buflen, int* offset) {
  // something already went wrong, just give up
  if (NullDecoder::is_error(m_status)) {
    return false;
  }
  ElfSymbolTable* symbol_table = m_symbol_tables;
  int string_table_index;
  int pos_in_string_table;
  int off = INT_MAX;
  bool found_symbol = false;
  while (symbol_table != NULL) {
    if (symbol_table->lookup(addr, &string_table_index, &pos_in_string_table, &off, m_funcDesc_table)) {
      found_symbol = true;
      break;
    }
    symbol_table = symbol_table->m_next;
  }
  if (!found_symbol) return false;

  ElfStringTable* string_table = get_string_table(string_table_index); /// <-- bad string_table_index if symbol_table->lookup returned bad "true"

  if (string_table == NULL) {
    m_status = NullDecoder::file_invalid;  /// <-- all future calls to ElfFile::decode will return false
    return false;
  }
  if (offset) *offset = off;

  return string_table->string_at(pos_in_string_table, buf, buflen);
}