KEMBAR78
Correctly unwind the stack for malloc events in VM stack walking mode by Baraa-Hasheesh · Pull Request #1357 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

Baraa-Hasheesh
Copy link
Contributor

Description

VM stack walker doesn't work on Malloc events which causes frames to not be unwound correctly

profiler.Malloc {
  startTime = 14:45:34.088
  address = 0x7F5F73F6A810
  size = 27 bytes
  eventThread = "DestroyJavaVM" (javaThreadId = 24)
  stackTrace = [
    .no_Java_frame() line: 0
  ]
}

Related issues

N/A

Motivation and context

Fix VM stack walker on malloc to avoid bad samples

How has this been tested?

added a native memory test with VM stack walking => was failing before change & now passes
make test


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

src/profiler.cpp Outdated
num_frames += StackWalker::walkVM(ucontext, frames + num_frames, _max_stack_depth, VM_NORMAL);
} else {
num_frames += getJavaTraceAsync(ucontext, frames + num_frames, _max_stack_depth, &java_ctx);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unwinding logic here is similar to unwinding stacktraces of regular CPU samples, so can we merge it with the above branch (event_type <= WALL_CLOCK_SAMPLE)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's possible but should I keep the inner if check for CPU samples only?

java_frames > 0 && java_ctx.pc != NULL && VMStructs::hasMethodStructs()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed offline updated here 48268c4

@apangin apangin merged commit 29dd537 into async-profiler:master Jul 1, 2025
18 checks passed
visheshruparelia pushed a commit to visheshruparelia/async-profiler that referenced this pull request Jul 9, 2025
visheshruparelia added a commit to visheshruparelia/async-profiler that referenced this pull request Jul 9, 2025
Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)

Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)
visheshruparelia added a commit to visheshruparelia/async-profiler that referenced this pull request Jul 9, 2025
Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)

Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)
visheshruparelia added a commit to visheshruparelia/async-profiler that referenced this pull request Jul 9, 2025
Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)

Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)
visheshruparelia added a commit to visheshruparelia/async-profiler that referenced this pull request Jul 9, 2025
Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)

Disable JFR OldObjectSample event in jfrsync mode (async-profiler#1350)

Fix invalid alignment in mallocTracer and zero-init buf in getTotalCpuTime (async-profiler#1351)

C++ linting via clang-tidy (async-profiler#1338)

Allow cstack=vmx for native applications (async-profiler#1354)

Correctly unwind stack for malloc events in VM stack walking mode (async-profiler#1357)

Simplify location handling in OTLP (async-profiler#1361)

Suppress javac warnings when compiling tests

Do not include excess files in test.jar

Fix nonjava test failure on Alpine

Auto-generated clang-tidy review comments (async-profiler#1360)

JFR to OTLP converter (async-profiler#1336)

Cancel redundant in-progress GHA runs (async-profiler#1363)

Ensure that only files under `src/` are checked in `cpp-lint-diff` (async-profiler#1365)

Publish clang-tidy comments only for non-draft PRs (async-profiler#1367)

Give tests unique suffix names (async-profiler#1371)

Test OTLP output format (async-profiler#1331)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants