GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deallocate jclass reference promptly by jbachorik · Pull Request #127 · DataDog/java-profiler

Conversation

@jbachorik

@jbachorik jbachorik commented Sep 6, 2024 •
edited by atlassian Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

What does this PR do?:
It adds defensive deallocation of jclass references to reduce the chance of crashing due to mismanaged jmethodID in JVM.

Motivation:
See async-profiler/async-profiler#981 and https://bugs.openjdk.org/browse/JDK-8268364

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-10461

Unsure? Have a question? Request a review!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions

github-actions Bot commented Sep 6, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

🔧 Report generated by pr-comment-scanbuild

Scan-Build Report

User:runner@fv-az2036-226
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 14.0.0-1ubuntu1.1
Date:Sun Sep 8 16:13:57 2024

Bug Summary

Bug TypeQuantityDisplay?
All Bugs5
Logic error
Assigned value is garbage or undefined1
Dereference of null pointer3
Unused code
Dead nested assignment1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Logic errorAssigned value is garbage or undefineddwarf.cppparseInstructions24420
Unused codeDead nested assignmentvmStructs.cppcheckNativeBinding8791
Logic errorDereference of null pointersafeAccess.hload3218
Logic errorDereference of null pointersymbols_linux.hElfParser12932
Logic errorDereference of null pointerflightRecorder.cppflush15088
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 6, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

🔧 Report generated by pr-comment-cppcheck

CppCheck Report

Warnings (5)

  • Obsolete function 'alloca' called.
  • Member variable 'ScopeDesc::_stream' is not initialized in the constructor.
  • Member variable 'ScopeDesc::_method_offset' is not initialized in the constructor.
  • Member variable 'ScopeDesc::_bci' is not initialized in the constructor.
  • Member variable 'ElfParser::_vaddr_diff' is not initialized in the constructor.

Style Violations (158)

  • Class 'AsyncSampleMutex' has a constructor with 1 argument that is not explicit.
  • Local variable 'jni' shadows outer function
  • Local variable 'size' shadows outer function
  • Local variable 'prev' shadows outer function
  • The class 'NativeFunc' does not declare a constructor although it has private member variables which likely require initialization.
  • Local variable 'count' shadows outer function
  • Local variable 'i' shadows outer variable
  • Consider using std::transform algorithm instead of a raw loop.
  • struct member 'Tag::value' is never used.
  • struct member 'ContextPage::capacity' is never used.
  • struct member 'ContextPage::storage' is never used.
  • The function 'check' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • Class 'Dictionary' has a constructor with 1 argument that is not explicit.
  • struct member 'DictRow::keys' is never used.
  • struct member 'DictRow::next' is never used.
  • Local variable 'pc_off' shadows outer variable
  • Class 'WallClockEpochEvent' has a constructor with 1 argument that is not explicit.
  • struct member 'QueueTimeEvent::_start' is never used.
  • struct member 'QueueTimeEvent::_end' is never used.
  • struct member 'QueueTimeEvent::_task' is never used.
  • struct member 'QueueTimeEvent::_scheduler' is never used.
  • struct member 'QueueTimeEvent::_origin' is never used.
  • The class 'VirtualSpaceSummary' does not declare a constructor although it has private member variables which likely require initialization.
  • The class 'GCHeapSummary' does not declare a constructor although it has private member variables which likely require initialization.
  • The class 'CollectedHeap' does not declare a constructor although it has private member variables which likely require initialization.
  • Class 'Element' has a constructor with 1 argument that is not explicit.
  • Class 'NoField' has a constructor with 1 argument that is not explicit.
  • Class 'MutexLocker' has a constructor with 1 argument that is not explicit.
  • Class 'MethodList' has a constructor with 1 argument that is not explicit.
  • Class 'ScopeDesc' has a constructor with 1 argument that is not explicit.
  • The function 'is_nofield' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'check' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'stop' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'interval' overrides a function in a base class but is not marked with a 'override' specifier.
  • Condition 'enabled()' is always false
  • Condition 'usage._maxSize==-1' is always false
  • The scope of the variable 'class_name_id' can be reduced.
  • The scope of the variable 'method_name_id' can be reduced.
  • The scope of the variable 'method_sig_id' can be reduced.
  • Variable 'class_name_id' is assigned a value that is never used.
  • Variable 'method_name_id' is assigned a value that is never used.
  • Variable 'method_sig_id' is assigned a value that is never used.
  • struct member 'CpuTime::real' is never used.
  • struct member 'CpuTime::user' is never used.
  • struct member 'CpuTime::system' is never used.
  • The function 'name' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'interval' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'check' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'stop' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'enableEvents' overrides a function in a base class but is not marked with a 'override' specifier.
  • struct member 'jvmtiStackInfoExtended::frame_buffer' is never used.
  • The class 'J9WallClock' does not declare a constructor although it has private member variables which likely require initialization.
  • The function 'name' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'interval' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'stop' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'enableEvents' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'name' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'interval' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'stop' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'enableEvents' overrides a function in a base class but is not marked with a 'override' specifier.
  • Unused variable: kept_classes
  • Condition 'level>=_level' is always true
  • Condition 'frames_size>0' is always true
  • The function 'rewind' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'next' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'size' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'check' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'start' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'enableEvents' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'registerThread' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'unregisterThread' overrides a function in a base class but is not marked with a 'override' specifier.
  • The function 'interval' overrides a function in a base class but is not marked with a 'override' specifier.
  • Variable 'error' is assigned a value that is never used.
  • Variable 'error' is assigned a value that is never used.
  • Variable 'error' is assigned a value that is never used.
  • Variable 'error' is assigned a value that is never used.
  • Unused private function: 'StackFrame::withinCurrentStack'
  • The comparison 'EMPTY_FRAME_SIZE > 0' is always false.
  • The comparison 'EMPTY_FRAME_SIZE > 0' is always false.
  • The scope of the variable 'prev_sp' can be reduced.
  • The comparison 'EMPTY_FRAME_SIZE > 0' is always false.
  • The comparison 'EMPTY_FRAME_SIZE > 0' is always false.
  • Class 'SymbolDesc' has a constructor with 1 argument that is not explicit.
  • Class 'MemoryMapDesc' has a constructor with 1 argument that is not explicit.
  • Local variable 'flag_addr' shadows outer variable
  • struct member 'ASGCT_CallTrace::env' is never used.
  • struct member 'ASGCT_CallTrace::frames' is never used.
  • struct member 'JVMTIFunctions::unused1' is never used.
  • struct member 'JVMTIFunctions::unused2' is never used.
  • The scope of the variable 'delayedCounter' can be reduced.
  • Variable 'error' is assigned a value that is never used.
  • The function 'GetJ9vmThread' is never used.
  • The function 'JNI_OnLoad' is never used.
  • The function 'JNI_OnUnload' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_currentTicks0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_describeDebugCounters0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_dump0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_execute0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_filterThread0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getContextPage0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getContextPageOffset0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getDebugCounters0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getMaxContextPages0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getSamples' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_getTid0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_mallocArenaMax0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_recordQueueEnd0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_recordSettingEvent0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_recordTrace0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_registerConstant0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_stop0' is never used.
  • The function 'Java_com_datadoghq_profiler_JavaProfiler_tscFrequency0' is never used.
  • The function '_min' is never used.
  • The function 'accept' is never used.
  • The function 'appendRecording' is never used.
  • The function 'arg0' is never used.
  • The function 'arg2' is never used.
  • The function 'assign' is never used.
  • The function 'body' is never used.
  • The function 'clearParsingCaches' is never used.
  • The function 'compiledMethod' is never used.
  • The function 'copyTo' is never used.
  • The function 'covers' is never used.
  • The function 'cpuMonitorCycle' is never used.
  • The function 'cputime' is never used.
  • The function 'deallocateLineNumberTable' is never used.
  • The function 'fileSize' is never used.
  • The function 'flushJfr' is never used.
  • The function 'fromHandle' is never used.
  • The function 'fromMethodID' is never used.
  • The function 'getCounter' is never used.
  • The function 'getJavaTraceInternal' is never used.
  • The function 'getJavaTraceJvmti' is never used.
  • The function 'getThreadId' is never used.
  • The function 'hasClassNames' is never used.
  • The function 'hasCompilerStructs' is never used.
  • The function 'inJava' is never used.
  • The function 'install' is never used.
  • The function 'isEntryFrame' is never used.
  • The function 'is_readable_pointer' is never used.
  • The function 'jarg0' is never used.
  • The function 'lastJavaFP' is never used.
  • The function 'notify' is never used.
  • The function 'ntoh64' is never used.
  • The function 'patchImport' is never used.
  • The function 'restart' is never used.
  • The function 'schedPolicy' is never used.
  • The function 'supported' is never used.
  • The function 'uninstall' is never used.
  • The function 'units' is never used.
  • The function 'updateCounter' is never used.
  • The function 'waitUntil' is never used.
  • The function 'writeListSetting' is never used.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbachorik
jbachorik requested a review from MattAlp September 6, 2024 11:14
@r1viollet

r1viollet commented Sep 6, 2024

Copy link
Copy Markdown
Contributor

I am not sure I understand why we have differences with upstream PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

richardstartin
richardstartin reviewed Sep 6, 2024
View reviewed changes
Comment thread ddprof-lib/src/main/cpp/flightRecorder.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jbachorik
jbachorik force-pushed the jb/deallocate_class branch from 81c06b0 to f461f9a Compare September 8, 2024 16:01
@jbachorik

jbachorik commented Sep 8, 2024

Copy link
Copy Markdown
Collaborator Author

I am not sure I understand why we have differences with upstream PR.

Because I started working on this before the final merge in the upstream. I have updated the diffs to be in-sync with what has been done upstream.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbachorik
Deallocate jclass reference promptly
e1c70a7
@jbachorik
jbachorik force-pushed the jb/deallocate_class branch from f461f9a to e1c70a7 Compare September 8, 2024 16:13
@jbachorik

jbachorik commented Sep 9, 2024

Copy link
Copy Markdown
Collaborator Author

Not needed. We are using push/pop frame to achieve the same effect already.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbachorik jbachorik closed this Sep 9, 2024
@jbachorik
jbachorik deleted the jb/deallocate_class branch September 9, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@MattAlp MattAlp Awaiting requested review from MattAlp
1 more reviewer
@richardstartin richardstartin richardstartin left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@jbachorik @r1viollet @richardstartin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.