Skip to content

feat(natsock): patch Netty's native epoll transport library by symbol - #730

Open
kaahos wants to merge 1 commit into
paul.fournillon/taskblock-native-iofrom
paul.fournillon/native_socket_netty
Open

feat(natsock): patch Netty's native epoll transport library by symbol#730
kaahos wants to merge 1 commit into
paul.fournillon/taskblock-native-iofrom
paul.fournillon/native_socket_netty

Conversation

@kaahos

@kaahos kaahos commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?:

Extends native socket patching to detect Netty's native epoll transport library (libnetty_transport_native_epoll*.so) by exported symbol, so it can be patched even when it lives outside the JDK's lib directory and its filename is relocated under shading (e.g. grpc-netty-shaded).

Motivation:

Netty's native epoll transport bypasses the JDK's socket path, so socket-related events were missed for applications using it.

Additional Notes:

Detection matches on JNI_OnLoad_netty_transport_native_epoll / JNI_OnUnload_netty_transport_native_epoll symbol pairs rather than basename, mirroring the existing IBM JCL bridge all-or-nothing check.

How to test the change?:

New unit tests in nativeSocketInterposer_ut.cpp cover plain and shaded Netty native epoll libraries, plus rejection when only one of the two symbols is present.

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 security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: [JIRA-XXXX]

Unsure? Have a question? Request a review!

@dd-octo-sts

dd-octo-sts Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #32473717914 | Commit: 7c8cc45 | Duration: 17m 16s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-08-21 11:11:36 UTC

@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from 9de97d6 to ddd6385 Compare August 16, 2026 14:26
@datadog-official

datadog-official Bot commented Aug 16, 2026

Copy link
Copy Markdown

Tests

🔄 Datadog auto-retried 2 jobs - 2 passed on retry View in Datadog

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0bd231e | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Scan-Build Report

User:runner@runnervm76f27
Working Directory:/home/runner/work/java-profiler/java-profiler/ddprof-lib/src/test/make
Command Line:make -j4 all
Clang Version:Ubuntu clang version 18.1.3 (1ubuntu1)
Date:Fri Aug 21 10:42:24 2026

Bug Summary

Bug TypeQuantityDisplay?
All Bugs1
Logic error
Dereference of null pointer1

Reports

Bug Group Bug Type ▾ File Function/Method Line Path Length
Logic errorDereference of null pointerprofiler.hfindLibraryByAddress63828

@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from ddd6385 to cdf93b0 Compare August 16, 2026 15:00
@dd-octo-sts

dd-octo-sts Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 0bd231e1

@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from cdf93b0 to 003c443 Compare August 16, 2026 18:24
@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from 003c443 to 1347a00 Compare August 17, 2026 12:38
@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from 1347a00 to 54c2392 Compare August 18, 2026 08:51
@dd-octo-sts

dd-octo-sts Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Reliability & Chaos Results

All reliability & chaos checks passed Pipeline: https://gitlab.ddbuild.io/DataDog/java-profiler/-/pipelines/132370831

@kaahos
kaahos force-pushed the paul.fournillon/native_socket_netty branch from 54c2392 to 0bd231e Compare August 21, 2026 10:40
@kaahos
kaahos marked this pull request as ready for review August 21, 2026 14:22
@kaahos
kaahos requested a review from a team as a code owner August 21, 2026 14:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bd231e185

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +65
if (lib->findSymbol("JNI_OnLoad_netty_transport_native_epoll") != nullptr &&
lib->findSymbol("JNI_OnUnload_netty_transport_native_epoll") != nullptr) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle Netty libraries that have already been unlinked

When the Netty transport was loaded before native-I/O profiling starts, this selector is never reached under Netty's default io.netty.native.deleteLibAfterLoading=true: the mapping name ends in (deleted), and patch_socket_functions() skips it when realpath(lib->name(), ...) fails at lines 833-835. This leaves the common already-loaded/restart case entirely unpatched; identify Netty from the in-memory CodeCache before requiring a resolvable filesystem path.

Useful? React with 👍 / 👎.

// Detection is by exported symbol rather than basename because the .so
// filename is relocated under shading (e.g. grpc-netty-shaded), while the
// JNI_OnLoad_/JNI_OnUnload_ suffix is not.
if (lib->findSymbol("JNI_OnLoad_netty_transport_native_epoll") != nullptr &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid scanning every library's full symbol table

On each library refresh while native-I/O hooks are active, every resolved DSO reaches this check before any basename or JDK-directory filtering, while CodeCache::findSymbol() performs a linear scan over all _count symbols. Large libraries such as libjvm contain far more than 256 entries, so loading one new DSO now rescans the complete symbol tables of all previously loaded libraries even when Netty is absent; cheaply narrow candidates first or provide an indexed exact-symbol lookup.

AGENTS.md reference: AGENTS.md:L385-L386

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant