GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecated sun.misc.Unsafe usage in vendored protobuf on JDK 25 · Issue #361 · grafana/pyroscope-java

Deprecated sun.misc.Unsafe usage in vendored protobuf on JDK 25 #361

New issue
Copy link
New issue
Copy link
Closed
#354
#365
Closed
Deprecated sun.misc.Unsafe usage in vendored protobuf on JDK 25#361
#354
#365
Copy link

Description

@indigo423
indigo423
opened on Sep 8, 2026
Issue body actions

When starting io.pyroscope:agent:2.9.1 in-process on JDK 25 (openjdk 25.0.4`, Ubuntu 24.04), the following warning is logged to stderr during startup:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by io.pyroscope.vendor.com.google.protobuf.UnsafeUtil$MemoryAccessor
WARNING: Please consider reporting this to the maintainers of class io.pyroscope.vendor.com.google.protobuf.UnsafeUtil$MemoryAccessor
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release

This is related to JEP 498. Because the protobuf runtime is shaded (io.pyroscope.vendor.*), downstream consumers cannot simply exclude or upgrade the dependency themselves. While users can temporarily defer the issue by passing --sun-misc-unsafe-memory-access=allow, the agent will break completely once arrayBaseOffset is removed in a future JDK release.

Minimal example for reproduction

  1. pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>pyroscope-repro</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>25</maven.compiler.source>
        <maven.compiler.target>25</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.pyroscope</groupId>
            <artifactId>agent</artifactId>
            <version>2.9.1</version>
        </dependency>
    </dependencies>
</project>
  1. src/main/java/Main.java
    Add a 15-second sleep so the agent's background thread has time to wake up and flush using Protobuf:
import io.pyroscope.javaagent.PyroscopeAgent;
import io.pyroscope.javaagent.config.Config;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        // Start the agent in-process
        PyroscopeAgent.start(Config.build());
        System.out.println("Pyroscope agent started. Waiting 15s for the first snapshot flush...");

        // Wait long enough for the agent to serialize and flush profile data
        Thread.sleep(15000);
    }
}
  1. mvn compile exec:exec -Dexec.executable="java" -Dexec.args="-cp %classpath Main"

Once the agent attempts to upload the snapshot (around the 10-second mark), it will invoke the vendored Protobuf code and you will see the Unsafe warning appear on stderr (along with a connection error since there is no Pyroscope server running locally, which is expected).

Activity

  1. korniltsev-grafanista commented on Sep 8, 2026

    @korniltsev-grafanista
    korniltsev-grafanista
    on Sep 8, 2026
    Contributor
    More actions

    Is there a fix in protobuf project? could not find it.

  2. korniltsev-grafanista-yolo-vibecoder239
    added a commit that references this issue on Sep 9, 2026

    perf(labels)!: encode the labels snapshot by hand, drop protobuf-java

    5e62701
  3. indigo423 commented on Sep 9, 2026

    @indigo423
    indigo423
    on Sep 9, 2026
    Author
    More actions

    Is there a fix in protobuf project? could not find it.

    Hi @korniltsev-grafanista thanks for taking care. I did a bit of a research and found this here: https://github.com/protocolbuffers/protobuf/releases/tag/v36.0. It seems like bumping to 4.36.1 might solve this issue.

    Reacted by Tolyan Korniltsev
  4. korniltsev-grafanista commented on Sep 9, 2026

    @korniltsev-grafanista
    korniltsev-grafanista
    on Sep 9, 2026
    Contributor
    More actions

    urgh my agent missed that. let me take a look

  5. korniltsev-grafanista commented on Sep 9, 2026

    @korniltsev-grafanista
    korniltsev-grafanista
    on Sep 9, 2026
    Contributor
    More actions

    I am inclined to replace the protobuf dependency with handwritten encoders, they turned out to be multiple times faster

    Reacted by Ronny Trommer
  6. indigo423 commented on Sep 9, 2026

    @indigo423
    indigo423
    on Sep 9, 2026
    Author
    More actions

    @korniltsev-grafanista happened a lot of times myself :)

  7. korniltsev-grafanista
    added a commit that references this issue on Sep 9, 2026

    fix: upgrade protobuf-java to 4.36.1 to stop using sun.misc.Unsafe (#365

    This issue will close once commit 2cc0cef is merged into the 'main' branch.
    2cc0cef
  8. korniltsev-grafanista
    closed this as completedin #365on Sep 9, 2026
  9. korniltsev-grafanista-yolo-vibecoder239
    added a commit that references this issue on Sep 9, 2026

    perf(labels)!: encode the labels snapshot by hand, drop protobuf-java

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.