JDK-8250750 : JDK-8247515 fix for OSX pc_to_symbol() lookup fails with some symbols
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2020-07-29
  • Updated: 2022-02-18
  • Resolved: 2020-08-03
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 16
16 b09Fixed
Related Reports
Relates :  
Description
JDK-8247515 fixed the OSX pc_to_symbol() lookup when using core files. I verified that it allows native symbols to show up in jstack output. However, I just noticed that it is failing with an address that is known to be a vtable, and for which there is a vtable symbol. After I looked into it, I discovered that the vtable symbol was properly in the symbol table used for the lookup, but lookup code was skipping the library that the address is in because it thought the address was outside of the address range of the library. The following code in pc_to_symbol() was skipping the library because the address range check failed.

    if (lib->symtab && addr >= lib->base && addr < lib->base + lib->memsz) {
      res = nearest_symbol(lib->symtab, addr - lib->base, poffset);
      if (res) return res;
    }

lib->memsz comes from the size of the LC_SEGMENT_64 that the library was discovered in. However, the library can actually span multiple segments. In this case of the vtable address, the address was in the segment that follows the initial LC_SEGMENT_64. Because of this lib->memsz is too small, resulting in symbol lookups being restricted to addresses that are in the initial segment.

The simplest approach to fixing this seems to be locating the largest offset found in the symbol table, round that up to a page boundary, and use it as lib->memsz. I've implemented this and it seems to be working.

Note the test for this will come when I finally have all issues like these resolved and can push my changes for JDK-8247514, which will include a ClhsdbFindPC test case that does "findpc" of an address known to be a vtable.
Comments
You could create a dependent PR for https://git.openjdk.java.net/jdk11u-dev/pull/832
18-02-2022

jdk11u fix request I would like to have the fix in 11 because the issue is present there too. Applies cleanly after JDK-8247515 is in jdk11u_dev, backport will be created after 8247515 is in jdk11u_dev.
17-02-2022

URL: https://hg.openjdk.java.net/jdk/jdk/rev/77b77ff0e8b9 User: cjplummer Date: 2020-08-03 23:14:09 +0000
03-08-2020