Skip to content

Fix #200 Crash related to aligned_alloc and free in context #208

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

Merged
merged 2 commits into from
Apr 28, 2025

Conversation

yanglong1010
Copy link
Contributor

@yanglong1010 yanglong1010 commented Apr 28, 2025

Hi, Could I have a review of this patch ?

What does this PR do?:
Fix #200

Motivation:
Replace aligned_alloc with posix_memalign

Additional Notes:
If posix_memalign can not alloc memory and returns a none-zero, we should avoid subsequent memory access, so return an empty ContextPage and the Java code check for this.

How to test the change?:
The following tests are passed:

  • gradle test
  • gradle testRelease

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: [JIRA-XXXX]

Unsure? Have a question? Request a review!

Copy link
Collaborator

@jbachorik jbachorik left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
Mostly, I am fine with the changes - just one small thing related to re-attempted page initialization, as described in the comment.

Comment on lines 272 to 275
ByteBuffer buffer = getContextPage0(tid);
if (buffer != null) {
contextStorage[pageIndex] = page = buffer.order(ByteOrder.LITTLE_ENDIAN);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will cause reattempting to allocate even though we are failing eg. due to memory shortage.
Would it make sense to use a sentinel ByteBuffer instance to signal that a page is not allocated but allocation was attempted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed

@jbachorik jbachorik merged commit ecabc7f into DataDog:main Apr 28, 2025
90 of 95 checks passed
@r1viollet
Copy link
Collaborator

Thank you for the change!

svc-squareup-copybara pushed a commit to cashapp/misk that referenced this pull request Jun 20, 2025
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
| [com.datadoghq:dd-trace-api](https://github.com/datadog/dd-trace-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`1.49.0` -> `1.50.0` |

---

### Release Notes

<details>
<summary>datadog/dd-trace-java (com.datadoghq:dd-trace-api)</summary>

###
[`v1.50.0`](https://github.com/DataDog/dd-trace-java/releases/tag/v1.50.0):
1.50.0

### Deprecation Notice

> \[!NOTE]
> `DD_RUNTIME_ID_ENABLED` has been deprecated and will be removed in
future releases. Please use `DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED`
instead.

### Components

#### Application Security Management (WAF)

- 🐛 Add String length truncation limit to ObjectIntrospector and
update truncation metrics
([#&#8203;8825](DataDog/dd-trace-java#8825) -
[@&#8203;jandro996](https://github.com/jandro996))
- 🐛 Adapt standalone ASM to support API Security
([#&#8203;8804](DataDog/dd-trace-java#8804) -
[@&#8203;jandro996](https://github.com/jandro996))
- ✨ Add appsec.waf.input\_truncated metric
([#&#8203;8791](DataDog/dd-trace-java#8791) -
[@&#8203;jandro996](https://github.com/jandro996))
- ✨ Extended appsec request body collection
([#&#8203;8748](DataDog/dd-trace-java#8748) -
[@&#8203;jandro996](https://github.com/jandro996))
- ✨ Extended appsec request/response headers collection
([#&#8203;8724](DataDog/dd-trace-java#8724) -
[@&#8203;jandro996](https://github.com/jandro996))

#### Build & Tooling

- ✨ Add artifacts to public s3 bucket
([#&#8203;8947](DataDog/dd-trace-java#8947) -
[@&#8203;randomanderson](https://github.com/randomanderson))

#### Continuous Integration Visibility

- ✨ Improve PR information building
([#&#8203;8908](DataDog/dd-trace-java#8908) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- ✨ Truncate span stack traces when Test Optimization is
enabled
([#&#8203;8903](DataDog/dd-trace-java#8903) -
[@&#8203;nikita-tkachenko-datadog](https://github.com/nikita-tkachenko-datadog))
- 🐛 Ensure auto-detected service name is the same for every process
in the same build
([#&#8203;8902](DataDog/dd-trace-java#8902) -
[@&#8203;nikita-tkachenko-datadog](https://github.com/nikita-tkachenko-datadog))
- 🐛 Use tag as fallback in api requests if no branch is available
([#&#8203;8876](DataDog/dd-trace-java#8876) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- ✨ Add support for JUnit 5.13-RC1
([#&#8203;8865](DataDog/dd-trace-java#8865),
[#&#8203;8871](DataDog/dd-trace-java#8871) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- ✨ Implement attempt to fix v3 and v4 and bump capability
version
([#&#8203;8824](DataDog/dd-trace-java#8824) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- 🧹 Align retry logic for all test framework instrumentations
([#&#8203;8803](DataDog/dd-trace-java#8803) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- 🐛 Always build ci workspace without trailing separator
([#&#8203;8788](DataDog/dd-trace-java#8788) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))
- ✨ Add commit discrepancies telemetry when building repository
git information
([#&#8203;8763](DataDog/dd-trace-java#8763) -
[@&#8203;daniel-mohedano](https://github.com/daniel-mohedano))

#### Data Streams Monitoring

- 💡 Surface process tags in dsm payloads and use them for base hash
calculation
([#&#8203;8836](DataDog/dd-trace-java#8836) -
[@&#8203;amarziali](https://github.com/amarziali))

#### Dynamic Instrumentation

- ✨ Optimized allocations for collection filter functions
([#&#8203;8896](DataDog/dd-trace-java#8896) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 🐛 Fix SymDB upload size check
([#&#8203;8887](DataDog/dd-trace-java#8887) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 🐛 Add support for Set in filter function
([#&#8203;8873](DataDog/dd-trace-java#8873) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 🐛 Add support for isDefined in log template
([#&#8203;8859](DataDog/dd-trace-java#8859) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 🐛 Fix Max captured frames for Exception Replay
([#&#8203;8856](DataDog/dd-trace-java#8856) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 🐛 Remove static inherited fields collection
([#&#8203;8832](DataDog/dd-trace-java#8832) -
[@&#8203;jpbempel](https://github.com/jpbempel))
- 💡 Add process tags to dynamic instrumentation intake payload
([#&#8203;8779](DataDog/dd-trace-java#8779) -
[@&#8203;amarziali](https://github.com/amarziali))

#### GraalVM native-image

- ✨ Add support for GraalVM Native GC metrics
([#&#8203;8913](DataDog/dd-trace-java#8913) -
[@&#8203;ygree](https://github.com/ygree))
- ✨ Add JMXFetch support for GraalVM Native
([#&#8203;8569](DataDog/dd-trace-java#8569) -
[@&#8203;ygree](https://github.com/ygree))

#### JMX fetch

- ✨ Add support for GraalVM Native GC metrics
([#&#8203;8913](DataDog/dd-trace-java#8913) -
[@&#8203;ygree](https://github.com/ygree))

#### Library Injection

- ✨ Deny oracle db jvm based tools
([#&#8203;8909](DataDog/dd-trace-java#8909) -
[@&#8203;bric3](https://github.com/bric3))

#### OpenTracing

- 🐛 Fix OT packaging for exception replay
([#&#8203;8912](DataDog/dd-trace-java#8912) -
[@&#8203;jpbempel](https://github.com/jpbempel))

#### Profiling

- ✨ Bump ddprof to 1.27.0
([#&#8203;8893](DataDog/dd-trace-java#8893) -
[@&#8203;jbachorik](https://github.com/jbachorik))
- Properly handle the adaptive sampling interval overflow by
[@&#8203;jbachorik](https://github.com/jbachorik) in
DataDog/java-profiler#213
- Fix [#&#8203;200](DataDog/dd-trace-java#200)
Crash related to aligned\_alloc and free in context by
[@&#8203;yanglong1010](https://github.com/yanglong1010) in
DataDog/java-profiler#208
- Explicitly initialize empty context page by
[@&#8203;jbachorik](https://github.com/jbachorik) in
DataDog/java-profiler#210
- Re-connect crash recursion protection with VM stackwalker by
[@&#8203;jbachorik](https://github.com/jbachorik) in
DataDog/java-profiler#214
- ✨ Enable ZSTD compression for profiling
([#&#8203;8862](DataDog/dd-trace-java#8862) -
[@&#8203;MattAlp](https://github.com/MattAlp))
- ✨ Extend JPS re-implementation to J9 family
([#&#8203;8813](DataDog/dd-trace-java#8813) -
[@&#8203;MattAlp](https://github.com/MattAlp))
- 💡 Collect process tags for profiling upload requests
([#&#8203;8780](DataDog/dd-trace-java#8780) -
[@&#8203;amarziali](https://github.com/amarziali))

#### Telemetry

- 💡 Surface process tags on telemetry payloads
([#&#8203;8837](DataDog/dd-trace-java#8837) -
[@&#8203;amarziali](https://github.com/amarziali))

#### Trace context propagation

- ✨ Migrating all HttpClient Instrumentations to Inject Full
Context
([#&#8203;8826](DataDog/dd-trace-java#8826) -
[@&#8203;mhlidd](https://github.com/mhlidd))
- ✨ Migrating all HttpServer Instrumentations to Extract full
Context
([#&#8203;8820](DataDog/dd-trace-java#8820) -
[@&#8203;mhlidd](https://github.com/mhlidd))
- ✨ Add context API support OTel propagators
([#&#8203;8770](DataDog/dd-trace-java#8770) -
[@&#8203;PerfectSlayer](https://github.com/PerfectSlayer))

#### Tracer core

- ✨⚡ Skip JAXB generated classes classloader
([#&#8203;9003](DataDog/dd-trace-java#9003) -
[@&#8203;bric3](https://github.com/bric3))
- ✨ Add DD\_RUNTIME\_METRICS\_RUNTIME\_ID\_ENABLED alias for
runtime id generation
([#&#8203;8981](DataDog/dd-trace-java#8981) -
[@&#8203;amarziali](https://github.com/amarziali))
- 🐛 Use resolved address for peer.hostname when available without
hitting the cache
([#&#8203;8915](DataDog/dd-trace-java#8915) -
[@&#8203;amarziali](https://github.com/amarziali))
- 💡 Surface server name process tag for tomcat
([#&#8203;8894](DataDog/dd-trace-java#8894) -
[@&#8203;amarziali](https://github.com/amarziali))
- 💡 Surface websphere cell and server name on process tags
([#&#8203;8880](DataDog/dd-trace-java#8880) -
[@&#8203;amarziali](https://github.com/amarziali))
- ✨ Added special lightweight pre-main class that skips
installation on incompatible JVMs.
([#&#8203;8855](DataDog/dd-trace-java#8855) -
[@&#8203;AlexeyKuznetsov-DD](https://github.com/AlexeyKuznetsov-DD))
- 💡 Add entrypoint type to process tags
([#&#8203;8839](DataDog/dd-trace-java#8839) -
[@&#8203;amarziali](https://github.com/amarziali))
- ✨ Extend JPS re-implementation to J9 family
([#&#8203;8813](DataDog/dd-trace-java#8813) -
[@&#8203;MattAlp](https://github.com/MattAlp))
- ✨ Notify listeners when the scope top changes after switching
scope stacks
([#&#8203;8797](DataDog/dd-trace-java#8797) -
[@&#8203;mcculls](https://github.com/mcculls))
- ✨ Read hsperfdata for Java PIDs if jvmstat is unavailable
([#&#8203;8792](DataDog/dd-trace-java#8792) -
[@&#8203;MattAlp](https://github.com/MattAlp))
- 🐛 Turn JDK socket support on by default
([#&#8203;8752](DataDog/dd-trace-java#8752) -
[@&#8203;sarahchen6](https://github.com/sarahchen6))
- ✨ Simplify context propagation
([#&#8203;8719](DataDog/dd-trace-java#8719) -
[@&#8203;PerfectSlayer](https://github.com/PerfectSlayer))
- ✨ Add JSON parsing support
([#&#8203;8579](DataDog/dd-trace-java#8579) -
[@&#8203;PerfectSlayer](https://github.com/PerfectSlayer))

#### Tracer internal logging

- ✨ Fix printing format of span identifiers
([#&#8203;8897](DataDog/dd-trace-java#8897) -
[@&#8203;vandonr](https://github.com/vandonr))

#### Tracer public API

- 💡 Track the source of installation
([#&#8203;8956](DataDog/dd-trace-java#8956) -
[@&#8203;mabdinur](https://github.com/mabdinur))
- ✨ Enforce size limit on application\_monitoring.yaml files
([#&#8203;8789](DataDog/dd-trace-java#8789) -
[@&#8203;mtoffl01](https://github.com/mtoffl01))
- ✨ Enabling baggage cache to support limits and non-ascii
characters
([#&#8203;8713](DataDog/dd-trace-java#8713) -
[@&#8203;mhlidd](https://github.com/mhlidd))

### Instrumentations

#### AWS Lambda instrumentation

- ✨ Pass Lambda Request ID to Extension
([#&#8203;8814](DataDog/dd-trace-java#8814) -
[@&#8203;nhulston](https://github.com/nhulston))

#### Core Java language instrumentation

- ✨ Ensure ClassloadingInstrumentation is always applied even
with `DD_TRACE_ENABLED=false`
([#&#8203;8863](DataDog/dd-trace-java#8863) -
[@&#8203;mcculls](https://github.com/mcculls))

#### Eclipse Vert.x instrumentation

- 🐛 Do not override route with / in vertx instrumentation
([#&#8203;8881](DataDog/dd-trace-java#8881) -
[@&#8203;vandonr](https://github.com/vandonr))

#### IBM Liberty

- 🐛 Fix error mark on http status for IBM liberty
([#&#8203;8822](DataDog/dd-trace-java#8822) -
[@&#8203;amarziali](https://github.com/amarziali))

#### JDBC instrumentation

- 🐛 Do not prepend DBM <> APM trace comment in SQLCommenter if there
is a pg plan hint
([#&#8203;8864](DataDog/dd-trace-java#8864) -
[@&#8203;edengorevoy](https://github.com/edengorevoy))

#### JMS instrumentation

- ✨ Add jms as an extra integration name where there is JMS
involved
([#&#8203;8933](DataDog/dd-trace-java#8933) -
[@&#8203;vandonr](https://github.com/vandonr))

#### Kotlin instrumentation

- ✨ Enable kotlin\_coroutine integration by default
([#&#8203;8848](DataDog/dd-trace-java#8848) -
[@&#8203;mcculls](https://github.com/mcculls))
- 🧹 Rework Kotlin coroutines instrumentation around coroutine
context
([#&#8203;8774](DataDog/dd-trace-java#8774) -
[@&#8203;mcculls](https://github.com/mcculls))

#### OpenTelemetry instrumentation

- 🐛 Support WithSpan inheritContext attribute
([#&#8203;8858](DataDog/dd-trace-java#8858) -
[@&#8203;amarziali](https://github.com/amarziali))
- ✨ Add context API support OTel propagators
([#&#8203;8770](DataDog/dd-trace-java#8770) -
[@&#8203;PerfectSlayer](https://github.com/PerfectSlayer))

#### Play Framework instrumentation

- 🐛 Fix the Play Framework's span resource name priority so that the
client JAX-RS 404 cannot override it
([#&#8203;8591](DataDog/dd-trace-java#8591) -
[@&#8203;ygree](https://github.com/ygree))

#### Quarkus Instrumentation

- 🐛 Ignore quarkus jaxrs stubs and cdi wrapper proxies
([#&#8203;8891](DataDog/dd-trace-java#8891) -
[@&#8203;amarziali](https://github.com/amarziali))

#### ServiceTalk

- ✨ Improve ServiceTalk Captured Context API Instrumentation
for v0.42.56+
([#&#8203;8821](DataDog/dd-trace-java#8821) -
[@&#8203;ygree](https://github.com/ygree))

#### Spring instrumentation

- ✨ Supporting Baggage for Instrumentations used in Weblog
Tests
([#&#8203;8773](DataDog/dd-trace-java#8773) -
[@&#8203;mhlidd](https://github.com/mhlidd))

#### WebSocket Instrumentation

- 💡 Trace websocket for spring webflux reactive handlers
([#&#8203;8831](DataDog/dd-trace-java#8831) -
[@&#8203;amarziali](https://github.com/amarziali))
- 💡:test\_tube: WebSocket support for Netty
([#&#8203;8632](DataDog/dd-trace-java#8632) -
[@&#8203;ValentinZakharov](https://github.com/ValentinZakharov))

#### Zio Instrumentation

- 🧹 Cleanup Zio fiber instrumentation to avoid repeated activation
of continuation
([#&#8203;8798](DataDog/dd-trace-java#8798) -
[@&#8203;mcculls](https://github.com/mcculls))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: 9207366cdb6a1bd098082305d354a0a3c4622d7a
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.

Crash related to aligned_alloc and free in context
3 participants