feat(natsock): patch Netty's native epoll transport library by symbol - #730
feat(natsock): patch Netty's native epoll transport library by symbol#730kaahos wants to merge 1 commit into
Conversation
CI Test ResultsRun: #32473717914 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-08-21 11:11:36 UTC |
9de97d6 to
ddd6385
Compare
|
🔄 Datadog auto-retried 2 jobs - 2 passed on retry 🔗 Commit SHA: 0bd231e | Docs | View more details | Give us feedback! |
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||
ddd6385 to
cdf93b0
Compare
cdf93b0 to
003c443
Compare
003c443 to
1347a00
Compare
1347a00 to
54c2392
Compare
Reliability & Chaos Results✅ All reliability & chaos checks passed Pipeline: https://gitlab.ddbuild.io/DataDog/java-profiler/-/pipelines/132370831 |
54c2392 to
0bd231e
Compare
There was a problem hiding this comment.
💡 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".
| if (lib->findSymbol("JNI_OnLoad_netty_transport_native_epoll") != nullptr && | ||
| lib->findSymbol("JNI_OnUnload_netty_transport_native_epoll") != nullptr) { |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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 👍 / 👎.
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_epollsymbol 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.cppcover plain and shaded Netty native epoll libraries, plus rejection when only one of the two symbols is present.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!