KEMBAR78
Options `--begin` and `--end` patch only the first occurrence of matching symbols · Issue #1247 · async-profiler/async-profiler · GitHub
Skip to content

Options --begin and --end patch only the first occurrence of matching symbols #1247

@fandreuz

Description

@fandreuz

Describe the bug

Spotted on Alpine while testing --ttsp:

$ objdump -tR /usr/lib/jvm/java-11-amazon-corretto/lib/server/libjvm.so | grep SafepointSynchronize  | grep begin
0000000000287338 l     F .text	0000000000000002              _ZN20SafepointSynchronize5beginEv.cold
0000000000ceaa60 l     F .text	0000000000003365              _ZN20SafepointSynchronize5beginEv
...

Profiler::resolveSymbols tries resolving SafepointSynchronize::begin, which is mangled to _ZN20SafepointSynchronize5beginE*, which is then resolved to _ZN20SafepointSynchronize5beginEv.cold. The patching then stops, and the other matching symbol is ignored altogether.

_ZN20SafepointSynchronize5beginEv.cold is some fallback version of SafepointSynchronize::begin:

(gdb) disass _entry
Dump of assembler code for function _ZN20SafepointSynchronize5beginEv.cold:
   0x00007ffff6eac338 <+0>:	ud2

Thus, patching it does not achieve the intended behavior of --begin.

This does not happen on e.g. amazonlinux:

$ objdump -tR ./java-17-amazon-corretto.x86_64/lib/server/libjvm.so | grep SafepointSynchronize | grep  begin
0000000000cb5150 l     F .text	000000000000084c              _ZN20SafepointSynchronize5beginEv

Thanks @krk for the debugging support.

Async-profiler version

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions