Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JavaFrameAnchor from TLS if available in vmstructs based stackwalker #186

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jbachorik
Copy link
Collaborator

@jbachorik jbachorik commented Feb 19, 2025

What does this PR do?:

Motivation:

Additional Notes:

How to test the change?:

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-11294

Unsure? Have a question? Request a review!

Copy link

github-actions bot commented Feb 19, 2025

🔧 Report generated by pr-comment-scanbuild

Scan-Build Report

User:runner@fv-az1374-933
Working Directory:/home/runner/work/java-profiler/java-profiler/ddprof-lib/src/test/make
Command Line:make -j4 clean all
Clang Version:Ubuntu clang version 18.1.3 (1ubuntu1)
Date:Thu Feb 20 14:19:11 2025

Bug Summary

Bug TypeQuantityDisplay?
All Bugs7
Logic error
Dereference of null pointer3
Suspicious operation
Bitwise shift1
Unused code
Dead initialization2
Dead nested assignment1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Suspicious operationBitwise shiftvmStructs.cppfind89716
Unused codeDead initializationjavaApi.cppJava_com_datadoghq_profiler_JavaProfiler_getStatus01161
Unused codeDead initializationstackWalker.cppwalkDwarf1661
Unused codeDead nested assignmentvmStructs.cppcheckNativeBinding10021
Logic errorDereference of null pointersafeAccess.hload3318
Logic errorDereference of null pointersymbols_linux.hElfParser14428
Logic errorDereference of null pointerflightRecorder.cppflush15048

Copy link

github-actions bot commented Feb 19, 2025

🔧 Report generated by pr-comment-cppcheck

CppCheck Report

Warnings (7)

Style Violations (398)

@jbachorik jbachorik force-pushed the jb/jf_anchor branch 2 times, most recently from 3ff61c5 to f9dd63f Compare February 20, 2025 13:45
const char *name = cc == NULL ? NULL : cc->binarySearch(pc);

if (name == nullptr) {
snprintf(hexBuffer, sizeof(hexBuffer), "%p", (uintptr_t)pc);

Check failure

Code scanning / CodeQL

Wrong type of arguments to formatting function High

This format specifier for type 'void *' does not match the argument type 'unsigned long'.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the format specifier matches the type of the argument passed to snprintf. Since pc is cast to uintptr_t, which is an unsigned integer type, we should use a format specifier that matches this type. The correct format specifier for an unsigned long integer is %lx or %lu depending on the exact type. In this case, %lx is appropriate for uintptr_t.

  • Change the format specifier from %p to %lx in the snprintf call.
  • This change should be made in the file ddprof-lib/src/main/cpp/stackWalker.cpp on line 427.
Suggested changeset 1
ddprof-lib/src/main/cpp/stackWalker.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ddprof-lib/src/main/cpp/stackWalker.cpp b/ddprof-lib/src/main/cpp/stackWalker.cpp
--- a/ddprof-lib/src/main/cpp/stackWalker.cpp
+++ b/ddprof-lib/src/main/cpp/stackWalker.cpp
@@ -426,3 +426,3 @@
       if (name == nullptr) {
-        snprintf(hexBuffer, sizeof(hexBuffer), "%p", (uintptr_t)pc);
+        snprintf(hexBuffer, sizeof(hexBuffer), "%lx", (uintptr_t)pc);
         name = hexBuffer;
EOF
@@ -426,3 +426,3 @@
if (name == nullptr) {
snprintf(hexBuffer, sizeof(hexBuffer), "%p", (uintptr_t)pc);
snprintf(hexBuffer, sizeof(hexBuffer), "%lx", (uintptr_t)pc);
name = hexBuffer;
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

1 participant