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

Prevent race condition in LivenessTracker #88

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Conversation

jbachorik
Copy link
Collaborator

@jbachorik jbachorik commented Apr 26, 2024

What does this PR do?:
Prevents a race condition leading to crash when a partially filled up tracking entry is accessed

Motivation:
Currently, the liveness tracking table is flushed under a shared lock. This allows for tracking part to add new elements in parallel, as they are run under shared lock as well. Most of the time this works fine, but if a table is being flushed and an entry is just partially filled in, with the ref set to non-null but frames still not set, this will lead to SIGSEG.

Additional Notes:
In addition to the change of locking mode, this PR contains a bunch of extra asserts and trivial changes to make the code more expressive and consistent.

Fixes #87

How to test the change?:
I was using the following command to provoke the crash

java -javaagent:dd-java-agent.jar -Ddd.profiling.enabled=true -Ddd.profiling.upload.period=5 -Ddd.profiling.start-force-first=true -Ddd.profiling.ddprof.liveheap.enabled=true -Xmx290m -jar renaissance-gpl-0.14.2.jar akka-uct -r 2000

The crashed followed within 15 minutes without this patch. With this patch I don't observe the crash after more than 4 hours of runtime.

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: SCP-425

Unsure? Have a question? Request a review!

@jbachorik jbachorik added this to the 1.5.0 milestone Apr 26, 2024
Copy link

🔧 Report generated by pr-comment-cppcheck

CppCheck Report

Warnings (5)

Style Violations (162)

Copy link

🔧 Report generated by pr-comment-scanbuild

Scan-Build Report

User:runner@fv-az979-609
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:Fri Apr 26 17:07:48 2024

Bug Summary

Bug TypeQuantityDisplay?
All Bugs6
Logic error
Assigned value is garbage or undefined1
Dereference of null pointer2
Result of operation is garbage or undefined1
Unused code
Dead initialization1
Dead nested assignment1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Logic errorAssigned value is garbage or undefineddwarf.cppparseInstructions23520
Unused codeDead initializationlivenessTracker.cppcleanup_table451
Unused codeDead nested assignmentvmStructs.cppcheckNativeBinding8181
Logic errorDereference of null pointerflightRecorder.cppflush14108
Logic errorDereference of null pointersafeAccess.hload3518
Logic errorResult of operation is garbage or undefineddwarf.hgetSLeb14225

@jbachorik jbachorik merged commit e6f367c into main Apr 29, 2024
28 checks passed
@jbachorik jbachorik deleted the jb/liveleak_race branch April 29, 2024 08:50
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.

[BUG] The jvm crashs with SIGSEGV after update dd-trace-java from 1.32.0 to 1.33.0
2 participants