[BUG] simpleperf associates wrong header file for lambda
@Jake-The-Human がすでに取り組んでいます。
2026年11月2日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 65/100
調査の方向性
pprof_proto_generator.pyから始めます。ここではFunction.keyとget_function_idが関数の重複排除とソースファイルの帰属を処理します。インラインフレームがsource_fileをどのように渡すかを追い、次にPprofProfileGeneratorの既存テストを確認して、異なるヘッダーにある同名のoperator()フレームが別個のものとして保持されることを示すテストを追加します。複数trialのプロファイルで各フレームのソースヘッダーが一貫して保持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
When llvm-symbolizer resolves inlined C++ lambdas or functors with --functions=linkage --demangle, it reports the unqualified function name operator(). Because Function.key in PprofProfileGenerator previously deduplicated functions solely by (name_id, dso_name_id) without source_filename_id, all inlined operator() frames within a binary shared a single Function record whose source_filename_id was overwritten by whichever sampled location was processed last. Across multi-trial profile aggregations, nondeterministic sampling caused the same inlined call site to be attributed to different header files in different trials, splitting identical call chains into separate flame graph branches.
For example, consider file Foo.cc that implements Foo class, has Foo::Bar() function that calls a lambda, and uses std::unique_ptr and std::vector. On different simpleperf runs, the lambda's operator() may be randomly associated with Foo.cc, unique_ptr.h, or vector.h.
A solution is to include source_filename_id in Function.key and pass the resolved source_file when creating or looking up Function records for inlined frames so that inlined functions with the same name in different files receive distinct Function entries.
Here's a patch that should solve this:
--- a/pprof_proto_generator.py
+++ b/pprof_proto_generator.py
@@ -249,17 +249,19 @@ class Mapping(object):
class Function(object):
- def __init__(self, name_id, dso_name_id, vaddr_in_dso):
+ def __init__(
+ self, name_id, dso_name_id, vaddr_in_dso, source_filename_id=0
+ ):
self.id = -1 # unset
self.name_id = name_id
self.dso_name_id = dso_name_id
self.vaddr_in_dso = vaddr_in_dso
- self.source_filename_id = 0
+ self.source_filename_id = source_filename_id
self.start_line = 0
@property
def key(self):
- return (self.name_id, self.dso_name_id)
+ return (self.name_id, self.dso_name_id, self.source_filename_id)
# pylint: disable=no-member
@@ -530,10 +532,17 @@ class PprofProfileGenerator(object):
def get_mapping(self, mapping_id):
return self.mapping_list[mapping_id - 1] if mapping_id > 0 else None
- def get_function_id(self, name, dso_name, vaddr_in_file):
+ def get_function_id(
+ self, name, dso_name, vaddr_in_file, source_filename=''
+ ):
if name == 'unknown':
return 0
- function = Function(self.get_string_id(name), self.get_string_id(dso_name), vaddr_in_file)
+ function = Function(
+ self.get_string_id(name),
+ self.get_string_id(dso_name),
+ vaddr_in_file,
+ self.get_string_id(source_filename),
+ )
exist_function = self.function_map.get(function.key)
if exist_function:
return exist_function.id
@@ -604,7 +613,9 @@ class PprofProfileGenerator(object):
# accurate when proguard mapping file is given.
function_id = orig_function_id
else:
- function_id = self.get_function_id(function_name, dso_name, 0)
+ function_id = self.get_function_id(
+ function_name, dso_name, 0, source_file
+ )
if function_id == 0:
continue
location.lines.append(self.add_line(source_file, source_line, function_id))
I am using a supported NDK
- I have checked and the NDK I'm using is currently supported
Affected versions
r27
- 主要言語
- 言語のデータがありません
- スター
- 2.3k
- フォーク
- 311
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
android/ndk のほかの issue
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 40/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
[BUG] error: PCH file was compiled for the target 'aarch64-unknown-linux-android21' but the current translation unit is being compiled for target 'aarch64-none-linux-android21'対応中かも @Sharjeel-Khan が 24 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 47/100
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
kunchenguid/firstmate#8796 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
swc-project/swc-next-issues#1043 ·
-
Inbox: numbered choices in a :::question become free text, and context bullets become the choicesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
backnotprop/plannotator#4132 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
When version > 2.4, Failed to Connect to the Backend Error: pkgJson.main?.endsWith is not a functionオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
antfu/node-modules-inspector#219 ·