Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

dd_oome_notifier.sh and dd_crash_uploader.sh fail when JDK_JAVA_OPTIONS contains JMX or other port-binding flags

オープン
#10,766 コメント 4 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@jbachorik がすでに取り組んでいます。

2026年3月12日 から。

評価

この issue はまだ評価されていません。

説明

type: bug report
Tracer Version(s)

1.55.0

Java Version(s)

21.0.9

JVM Vendor

Eclipse Adoptium / Temurin

Bug Report

The dd_oome_notifier.sh (and dd_crash_uploader.sh) scripts spawned via -XX:OnOutOfMemoryError do not unset JDK_JAVA_OPTIONS, JAVA_TOOL_OPTIONS, or _JAVA_OPTIONS before launching a child java process. The child JVM therefore inherits the full application JVM configuration, which causes three distinct problems:

  1. Port conflicts — flags like JMX remote (-Dcom.sun.management.jmxremote.port=9012) cause BindException because the parent JVM still holds the port
  2. cgroup OOMKill — memory flags like -Xms/-Xmx or -XX:MaxRAMPercentage=90 cause the child JVM to compete with the still-alive parent for container memory, potentially triggering a kernel OOMKill
  3. Lost OOM diagnostics — when the script fails for any of the above reasons, no OOME event reaches Datadog, and the original OOM exception details (stack trace, thread name) are also lost because -XX:+ExitOnOutOfMemoryError force-terminates after the handler runs

Actual output:

# java.lang.OutOfMemoryError: Metaspace
# -XX:OnOutOfMemoryError="/tmp/datadog/java/dd_oome_notifier.sh %p"
#   Executing /bin/sh -c "/tmp/datadog/java/dd_oome_notifier.sh 1"...
Agent Jar: /opt/datadog/apm/library/java/dd-java-agent.jar
Tags: host:order-664fc65797-2bclc,...
JAVA_HOME: /opt/java/openjdk
PID: 1
NOTE: Picked up JDK_JAVA_OPTIONS: -XX:MaxGCPauseMillis=4000 -XX:MinRAMPercentage=25 -XX:MaxRAMPercentage=90 -XX:MaxMetaspaceSize=128m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9012 -Dcom.sun.management.jmxremote.rmi.port=9012 ...
Picked up JAVA_TOOL_OPTIONS: -javaagent:/opt/datadog/apm/library/java/dd-java-agent.jar ...

Caused by: java.rmi.server.ExportException: Port already in use: 9012; nested exception is:
	java.net.BindException: Address already in use
	...
Error: Failed to generate OOME event
Terminating due to java.lang.OutOfMemoryError: Metaspace
Expected Behavior

The OOME event should be sent to Datadog successfully, regardless of what JDK_JAVA_OPTIONS or JAVA_TOOL_OPTIONS contain. When the script fails, the original OOM exception details (stack trace, thread name) should still be visible in the application logs.

Reproduction Code
  1. Configure a JVM application with JMX remote monitoring via JDK_JAVA_OPTIONS:

    JDK_JAVA_OPTIONS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9012 -Dcom.sun.management.jmxremote.rmi.port=9012 ...
    
  2. Have dd-java-agent injected (e.g. via Admission Controller), which sets:

    JAVA_TOOL_OPTIONS=-javaagent:/opt/datadog/apm/library/java/dd-java-agent.jar -XX:OnOutOfMemoryError="/tmp/datadog/java/dd_oome_notifier.sh %p"
    
  3. Trigger an OutOfMemoryError (in our case: java.lang.OutOfMemoryError: Metaspace)

  4. The JVM invokes dd_oome_notifier.sh, which spawns a child java process:

    "$config_java_home/bin/java" -Ddd.dogstatsd.start-delay=0 -jar "$config_agent" sendOomeEvent "$config_tags"
    
  5. This child process inherits JDK_JAVA_OPTIONS (including JMX port flags) and JAVA_TOOL_OPTIONS (including the agent jar) from the environment.

  6. The child JVM tries to bind JMX to port 9012, which is still held by the dying parent JVM → BindException: Address already in use → "Error: Failed to generate OOME event"

主要言語
Java
スター
736
フォーク
364
平均マージ
3日 13時間
マージ済み PR(30日)
213

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DataDog/dd-trace-java のほかの issue

DataDog/dd-trace-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。