Skip to content

Handling Java profiling exceptions #968

@prashantbytesyntax

Description

@prashantbytesyntax

During Java profiling with gProfiler, exceptions and crashes are observed in:

  1. jattach: A lightweight tool used to communicate with the JVM Attach Listener.
  2. Async-profiler: A low-overhead Java profiler that interacts with the JVM.

Trace
[2025-04-29 08:02:04,975] ERROR: gprofiler.profilers.profiler_base: JavaProfiler: failed to profile process <process_id> Traceback (most recent call last): File "gprofiler/profilers/profiler_base.py", line 143, in _wait_for_profiles File "concurrent/futures/_base.py", line 451, in result File "concurrent/futures/_base.py", line 403, in __get_result File "concurrent/futures/thread.py", line 58, in run File "gprofiler/profilers/java.py", line 1283, in _profile_process File "gprofiler/profilers/java.py", line 1305, in _profile_ap_process File "gprofiler/profilers/java.py", line 811, in start_async_profiler File "gprofiler/profilers/java.py", line 770, in _run_async_profiler gprofiler.profilers.java.JattachSocketMissingException: Command ['/tmp/_MEIPXzD02/gprofiler/resources/java/asprof', '21644', 'load', '/tmp/gprofiler_tmp/async-profiler-v3.0g1/glibc/libasyncProfiler.so', 'true', 'start,event=cpu,file=/tmp/gprofiler_tmp/tmp645x_mxv/async-profiler-21644.output,collapsed,ann,sig,interval=90909090,log=/tmp/gprofiler_tmp/tmp645x_mxv/async-profiler-21644.log,fdtransfer=@async-profiler-<process_id>-<id>,safemode=0,,features=probesp+vtable,timeout=90'] returned non-zero exit status 1. stdout: stderr: Could not start attach mechanism: No such file or directory

These issues manifest as:

  1. Core dumps: Generated due to crashes in jattach or async-profiler, consuming significant disk space.
  2. Profiling interruptions: Profiling sessions fail due to invalid attach requests or missing resources.

Suggested Improvements :

  1. Add an Option in gProfiler to Disable Core Dumps for Async-Profiler and jattach
  2. Add a Check for Attach Socket File Before Starting Async-Profiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    TriagingNeed to understand the issue more with triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions