Should not access the thread states of none Java threads#346
Should not access the thread states of none Java threads#346zhengyu123 merged 11 commits intomainfrom
Conversation
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_java_thread = raw_thread_state >= 4 && raw_thread_state < 12; | ||
|
|
||
| return is_java_thread ? convertJvmExecutionState(raw_thread_state) | ||
| : ExecutionMode::JVM; |
There was a problem hiding this comment.
If we are running this only for is_java_thread will we ever get to execute the 'false' branch here?
There was a problem hiding this comment.
Not quite sure what you mean - there is a second check is_java_thread = raw_thread_state >= 4 && raw_thread_state < 12; in old code that overwrites is_java_thread value, so it is possible to reach false branch.
There was a problem hiding this comment.
How can we get non-java specific states in a java thread?
Or is is_java_thread rather is_in_java_thread_state after the overwriting?
There was a problem hiding this comment.
The first is_java_thread check guarantees that this thread is a java - this block of code is inherited from old code.
If it fails the first is_java_thread check, then it is a JVM internal thread - always return ExecutionMode::JVM before we have better solution,
There was a problem hiding this comment.
Ok, I am fine. Just put a bit of explanatory doc there for the future. Otherwise, no objections to merging
jbachorik
left a comment
There was a problem hiding this comment.
Approved, pending the clarification about getThreadExecutionMode changes
| switchThreadEvents(JVMTI_ENABLE); | ||
|
|
||
| // Initialize this thread | ||
| onThreadStart(nullptr, nullptr, nullptr); |
There was a problem hiding this comment.
Nit: May update the doc for this function to mention that it allows all-null values and what that means
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
What does this PR do?:
Profiler should not access the thread states of none Java threads.
Motivation:
Thread state is only defined for Java thread - accessing the thread state of a none Java thread can lead to crash, as the memory may not be valid.
Additional Notes:
Nativethreads, as they are largely running inNativestate.BaseContextWallClockTest.javais necessary, asJvmtiBasedContextWallClockTest.javais safepoint biased, threads are either inSafepointor inNativestatesHow to test the change?:
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!