oracle / visualvm

VisualVM is an All-in-One Java Troubleshooting Tool
https://visualvm.github.io/
Other
2.89k stars 305 forks source link

Can't connect to a local Linux process by attaching to the PID or via JMX #612

Open 0x6675636b796f75676974687562 opened 1 month ago

0x6675636b796f75676974687562 commented 1 month ago

Describe the bug

I'm running the latest released VisualVM version (2.1.0) and Java 17. On Linux, I can't connect to a local process by either attaching to its PID or via JMX. At the same time, it's fully possible to do the same using JConsole or JMC (see the screenshots below).

To Reproduce Steps to reproduce the behavior:

  1. Launch the SwingSet2.jar demo application shipped with the JDK, with JMX agent explicitly enabled:
    • -Djava.net.preferIPv4Stack=true
    • -Dcom.sun.management.jmxremote=true
    • -Dcom.sun.management.jmxremote.port=2048
    • -Dcom.sun.management.jmxremote.rmi.port=2048
    • -Dcom.sun.management.jmxremote.local.only=false
    • -Dcom.sun.management.jmxremote.authenticate=false
    • -Dcom.sun.management.jmxremote.ssl=false
  2. Try to connect to the process with JConsole or JMC, by either attaching to the local PID, or by connecting to 127.0.0.1:2048 via JMX. The operation succeeds.
  3. Try to do the same with VisualVM.
  4. When connecting via JMX, and empty Overview tab will open (no system properties, no nothing).
  5. When attaching to the PID, VisualVM will display an indeterminate progress bar at the lower right corner of its screen, with a message: "Opening XYZ (pid 123)..."

Expected behavior VisualVM should be able to attach to a JVM process.

VisualVM log

Details

```console Picked up _JAVA_OPTIONS: -Dswing.metalTheme=steel -Dswing.boldMetal=true ------------------------------------------------------------------------------- >Log Session: Thursday, October 17, 2024 at 1:23:56 PM Moscow Standard Time >System Info: Product Version = VisualVM 2.1.10 Operating System = Linux version 5.15.153.1-microsoft-standard-WSL2 running on amd64 Java; VM; Vendor = 17.0.12; OpenJDK 64-Bit Server VM 17.0.12+7-Debian-2deb12u1; Debian Runtime = OpenJDK Runtime Environment 17.0.12+7-Debian-2deb12u1 Java Home = /usr/lib/jvm/java-17-openjdk-amd64 System Locale; Encoding = en_US (visualvm); UTF-8 Home Directory = /home/a00664975 Current Directory = /home/a00664975/docs/programming/java/kirin/kirin/kirin-cli/target User Directory = /home/a00664975/.visualvm/2.1.10 Cache Directory = /home/a00664975/.cache/visualvm/2.1.10 Installation = /home/a00664975/.sdkman/candidates/visualvm/current/visualvm /home/a00664975/.sdkman/candidates/visualvm/current/platform Boot & Ext. Classpath = Application Classpath = /home/a00664975/.sdkman/candidates/visualvm/current/platform/lib/boot.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platfo rm/lib/org-openide-modules.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platform/lib/org-openide-util.jar:/home/a00664975/.sdkman/candidates/visualvm /current/platform/lib/org-openide-util-lookup.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platform/lib/org-openide-util-ui.jar Startup Classpath = /home/a00664975/.sdkman/candidates/visualvm/current/platform/core/org-netbeans-libs-asm.jar:/home/a00664975/.sdkman/candidates/visua lvm/current/platform/core/org-openide-filesystems.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platform/core/asm-9.7.jar:/home/a00664975/.sdkman/cand idates/visualvm/current/platform/core/core.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platform/core/asm-commons-9.7.jar:/home/a00664975/.sdkman/can didates/visualvm/current/platform/core/core-base.jar:/home/a00664975/.sdkman/candidates/visualvm/current/platform/core/asm-tree-9.7.jar:/home/a00664975/.sdkman/ candidates/visualvm/current/visualvm/core/org-graalvm-visualvm-modules-startup.jar:/home/a00664975/.sdkman/candidates/visualvm/current/visualvm/core/locale/core _visualvm.jar ------------------------------------------------------------------------------- WARNING [org.netbeans.core.modules]: had to upgrade dependencies for module net.java.dev.tda.visualvm: added = [module org.netbeans.modules.options.api/1 > 1.4] removed = [module org.netbeans.modules.options.api/0-1 > 1.5.1]; details: [Major release version of module changed from 0 to 1 to signal stability; update your dependencies] WARNING [org.netbeans.core.modules]: had to upgrade dependencies for module net.java.dev.tda.visualvm.logfile: added = [module org.openide.util.lookup > 8.0] re moved = []; details: [#170056: Separate module for Lookup API] WARNING [org.netbeans.core.modules]: module com.oracle.coherence.plugin.visualvm does not declare OpenIDE-Module-Public-Packages in its manifest, so all package s are considered public by default: http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-vers WARNING [org.netbeans.core.projects.cache]: layer jar:file:/home/a00664975/.visualvm/2.1.10/modules/com-oracle-coherence-plugin-visualvm-coherence-visualvm-plug in.jar!/com/oracle/coherence/plugin/visualvm/layer.xml contains duplicate folders named VisualVM/ExplorerPopupSelection WARNING [org.netbeans.core.projects.cache]: layer jar:file:/home/a00664975/.visualvm/2.1.10/modules/com-oracle-coherence-plugin-visualvm-coherence-visualvm-plug in.jar!/com/oracle/coherence/plugin/visualvm/layer.xml contains duplicate folders named VisualVM/ExplorerPopupNoSelection WARNING: A terminally deprecated method in java.lang.System has been called WARNING: System::setSecurityManager has been called by org.netbeans.TopSecurityManager (file:/home/a00664975/.sdkman/candidates/visualvm/2.1.10/platform/lib/boo t.jar) WARNING: Please consider reporting this to the maintainers of org.netbeans.TopSecurityManager WARNING: System::setSecurityManager will be removed in a future release INFO [org.netbeans.core.startup.NbEvents]: Turning on modules: org.openide.util.lookup [8.58 20240628-0d0bfcf3fa] org.openide.util [9.32 20240628-0d0bfcf3fa] org.openide.util.ui [9.33 20240628-0d0bfcf3fa] org.openide.modules [7.72 20240628-0d0bfcf3fa] org.netbeans.api.progress/1 [1.72 20240628-0d0bfcf3fa] org.netbeans.api.annotations.common/1 [1.52 20240628-0d0bfcf3fa] org.openide.filesystems [9.37 20240628-0d0bfcf3fa] org.openide.awt [7.92 20240628-0d0bfcf3fa] org.netbeans.swing.plaf [1.66 20240628-0d0bfcf3fa] org.netbeans.api.progress.nb [1.72 20240628-0d0bfcf3fa] org.openide.dialogs [7.71 20240628-0d0bfcf3fa] org.openide.nodes [7.69 20240628-0d0bfcf3fa] org.openide.windows [6.101 20240628-0d0bfcf3fa] org.netbeans.swing.tabcontrol [1.81 20240628-0d0bfcf3fa] org.netbeans.swing.outline [1.58 20240628-0d0bfcf3fa] org.openide.explorer [6.86 20240628-0d0bfcf3fa] org.netbeans.modules.editor.mimelookup/1 [1.64 20240628-0d0bfcf3fa] org.openide.text [6.92 20240628-0d0bfcf3fa] org.openide.actions [6.63 20240628-0d0bfcf3fa] org.netbeans.modules.keyring [1.48 20240628-0d0bfcf3fa] org.netbeans.api.intent [1.26 20240628-0d0bfcf3fa] org.netbeans.api.io [1.27 20240628-0d0bfcf3fa] org.openide.io [1.73 20240628-0d0bfcf3fa] org.netbeans.libs.asm [5.27 20240628-0d0bfcf3fa] org.netbeans.bootstrap/1 [2.103 20240628-0d0bfcf3fa] org.netbeans.core.startup.base [1.86.0.1 1 20240628-0d0bfcf3fa] org.netbeans.core.startup/1 [1.87.0.1 20240628-0d0bfcf3fa] org.netbeans.modules.sampler [1.38 20240628-0d0bfcf3fa] org.netbeans.api.scripting [1.21 20240628-0d0bfcf3fa] org.netbeans.modules.queries/1 [1.67 20240628-0d0bfcf3fa] org.netbeans.api.templates [1.32 20240628-0d0bfcf3fa] org.openide.filesystems.nb [9.34 20240628-0d0bfcf3fa] org.openide.loaders [7.94 20240628-0d0bfcf3fa] org.netbeans.core/2 [3.75 20240628-0d0bfcf3fa] org.netbeans.spi.quicksearch [1.51 20240628-0d0bfcf3fa] org.netbeans.modules.options.api/1 [1.69 20240628-0d0bfcf3fa] org.graalvm.visualvm.lib.charts/2 [2.1 240911] org.graalvm.visualvm.lib.jfluid/2 [2.18 240911] org.graalvm.visualvm.lib.common/2 [2.11 240911] org.graalvm.visualvm.lib.profiler.api/2 [2.2 240911] org.graalvm.visualvm.lib.ui/2 [2.4 240911] org.graalvm.visualvm.uisupport/2 [2.1 240911] org.netbeans.modules.sendopts/2 [2.60 20240628-0d0bfcf3fa] org.graalvm.visualvm.core/2 [2.4 240911] org.graalvm.visualvm.modules.tracer/2 [2.1 220117] org.graalvm.visualvm.host/2 [2.1 240911] org.graalvm.visualvm.application/2 [2.4 240911] org.openjdk.btrace.visualvm.api [2.2.2 220411] org.graalvm.visualvm.tools/2 [2.3 240911] org.graalvm.visualvm.modules.tracer.dynamic/2 [2.1 211018] org.openjdk.btrace.visualvm.tracer.deployer [2.1.0 210714] org.graalvm.visualvm.coredump/2 [2.1 240911] org.graalvm.visualvm.threaddump/2 [2.1 240911] org.graalvm.visualvm.charts/2 [2.1 240911] org.graalvm.visualvm.lib.jfluid.heap [1.3 240911] org.graalvm.visualvm.lib.profiler.oql/2 [2.0 240911] org.graalvm.visualvm.lib.profiler.utilities/2 [2.0 240911] org.netbeans.modules.settings/1 [1.73 20240628-0d0bfcf3fa] org.netbeans.core.windows/2 [2.109 20240628-0d0bfcf3fa] org.graalvm.visualvm.lib.profiler.attach/2 [2.3 240911] org.graalvm.visualvm.lib.profiler/2 [2.4 240911] org.graalvm.visualvm.lib.profiler.heapwalker/2 [2.2 240911] org.netbeans.modules.autoupdate.services [1.80 20240628-0d0bfcf3fa] org.netbeans.modules.autoupdate.ui [1.70 20240628-0d0bfcf3fa] org.graalvm.visualvm.heapviewer/2 [2.8 240911] org.graalvm.visualvm.heapdump/2 [2.1 240911] org.graalvm.visualvm.application.views/2 [2.1 240911] jsyntaxpane.lib/1 [0.9.4.3 200207] org.openjdk.btrace.visualvm/2 [2.1.0 210714] org.netbeans.libs.flatlaf/1 [1.18 3.3 20240628-0d0bfcf3fa] org.netbeans.swing.laf.flatlaf [1.17 20240628-0d0bfcf3fa] org.netbeans.modules.progress.ui [1.57 20240628-0d0bfcf3fa] org.netbeans.modules.options.keymap [1.61 20240628-0d0bfcf3fa] org.netbeans.modules.masterfs/2 [2.79.0.2 2 20240628-0d0bfcf3fa] org.netbeans.modules.masterfs.ui [2.27.0.2 20240628-0d0bfcf3fa] org.netbeans.modules.masterfs.nio2 [1.39 20240628-0d0bfcf3fa] org.netbeans.libs.jna/2 [2.19 20240628-0d0bfcf3fa] org.netbeans.modules.masterfs.linux [1.37 20240628-0d0bfcf3fa] org.netbeans.modules.keyring.fallback [1.32 20240628-0d0bfcf3fa] org.netbeans.modules.keyring.impl [1.48 20240628-0d0bfcf3fa] org.netbeans.modules.editor.mimelookup.impl/1 [1.56 20240628-0d0bfcf3fa] org.netbeans.modules.autoupdate.cli [1.38 20240628-0d0bfcf3fa] org.netbeans.libs.jna.platform/2 [2.19 20240628-0d0bfcf3fa] org.netbeans.core.ui/1 [1.69 20240628-0d0bfcf3fa] org.netbeans.core.network [1.36 20240628-0d0bfcf3fa] org.netbeans.core.nativeaccess/1 [1.55 20240628-0d0bfcf3fa] org.netbeans.core.multitabs/1 [1.36.0.1 1 20240628-0d0bfcf3fa] org.netbeans.core.io.ui/1 [1.54 20240628-0d0bfcf3fa] org.graalvm.visualvm.lib.profiler.snaptracer/2 [2.0 240911] org.graalvm.visualvm.profiling/2 [2.3 240911] org.graalvm.visualvm.sampler.truffle/2 [2.1 240911] org.graalvm.visualvm.sampler/2 [2.2 240911] org.graalvm.visualvm.sa/2 [2.0 240911] org.graalvm.visualvm.modules.startup/2 [2.1 240911] org.graalvm.visualvm.profiler/2 [2.1 240911] org.graalvm.visualvm.profiler.startup/2 [2.0 200207] org.graalvm.visualvm.pluginimporter [1.0 240911] org.graalvm.visualvm.modules.visualgc [2.1.3 200207] org.graalvm.visualvm.modules.tracer.swing/2 [2.2 211018] org.graalvm.visualvm.modules.tracer.monitor/2 [2.0 200207] org.graalvm.visualvm.modules.tracer.jvmstat/2 [2.0 200207] org.graalvm.visualvm.modules.tracer.jvm/2 [2.2 220117] org.graalvm.visualvm.modules.tracer.javafx/2 [2.2 211018] org.graalvm.visualvm.modules.tracer.io/2 [2.2 211018] org.graalvm.visualvm.modules.tracer.collections/2 [2.2 211018] org.graalvm.visualvm.modules.threadinspect/2 [2.0 200207] org.graalvm.visualvm.modules.security/2 [2.0 200207] org.graalvm.visualvm.modules.oqlsyntax/2 [2.0 200207] org.graalvm.visualvm.modules.nashorn.jdk15 [1.1 240911] org.graalvm.visualvm.modules.mbeans/2 [2.0 200207] org.graalvm.visualvm.modules.killapp/1 [1.2 200207] org.graalvm.visualvm.modules.jconsole/2 [2.0 200207] org.graalvm.visualvm.modules.graaljs [1.3 230401] org.graalvm.visualvm.modules.extensions/2 [2.0 200207] org.graalvm.visualvm.modules.buffermonitor/2 [2.0 200207] org.graalvm.visualvm.modules.appui/2 [2.1 240911] org.graalvm.visualvm.jvmstat/2 [2.0 240911] org.graalvm.visualvm.jvm/2 [2.0 240911] org.graalvm.visualvm.jmx/2 [2.2 240911] org.graalvm.visualvm.host.views/2 [2.0 240911] org.graalvm.visualvm.jfr.streaming [1.5 240911] org.graalvm.visualvm.jfr/2 [2.3 240911] org.graalvm.visualvm.jfr.jdk11/2 [2.2 240911] org.graalvm.visualvm.jfr.generic/2 [2.5 240911] org.graalvm.visualvm.host.remote/2 [2.0 240911] org.graalvm.visualvm.heapviewer.truffle/2 [2.1 240911] org.graalvm.visualvm.heapviewer.console/2 [2.0 240911] org.graalvm.visualvm.graalvm/2 [2.0 240911] org.graalvm.visualvm.gotosource/2 [2.0 240911] org.graalvm.visualvm.attach/2 [2.0 240911] net.java.dev.tda/2 [2.4 200909] net.java.dev.tda.visualvm.logfile/2 [2.4 200909] net.java.dev.tda.visualvm/2 [2.4 200909] com.oracle.coherence.plugin.visualvm [1.7.1 1.7.1-20240718 202407180808] INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy resolver: no suitable found, using fallback. INFO [org.netbeans.core.network.proxy.fallback.FallbackNetworkProxy]: Fallback system proxy resolver: http_proxy=http://localhost:3128 INFO [org.netbeans.core.network.proxy.fallback.FallbackNetworkProxy]: Fallback system proxy resolver: https_proxy=http://localhost:3128 INFO [org.netbeans.core.network.proxy.fallback.FallbackNetworkProxy]: Fallback system proxy resolver: socks_proxy=null INFO [org.netbeans.core.network.proxy.fallback.FallbackNetworkProxy]: Fallback system proxy resolver: no_proxy=null INFO [org.netbeans.core.network.proxy.fallback.FallbackNetworkProxy]: Fallback system proxy resolver: no proxy set to default INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy reloading succeeded. INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - mode: manual INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - http host: localhost INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - http port: 3128 INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - https host: localhost INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - https port: 3128 INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - socks host: INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - socks port: INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - no proxy hosts: localhost|127.0.0.1 INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy TEST - http host: localhost INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy TEST - http port: 3128 INFO [org.netbeans.ui.metrics.laf]: USG_LOOK_AND_FEEL Diagnostic information Input arguments: -Djdk.home=/usr/lib/jvm/java-17-openjdk-amd64 -Dnetbeans.default_userdir_root=/home/a00664975/.visualvm -Dnetbeans.dirs=/home/a00664975/.sdkman/candidates/visualvm/current/visualvm: -Dnetbeans.home=/home/a00664975/.sdkman/candidates/visualvm/current/platform -Xms24m -Xmx16g -Dnetbeans.accept_license_class=org.graalvm.visualvm.modules.startup.AcceptLicense -Dnetbeans.importclass=org.graalvm.visualvm.modules.startup.ImportSettings -Dsun.jvmstat.perdata.syncWaitMs=10000 -Dsun.java2d.noddraw=true -Dsun.java2d.d3d=false -Dorg.netbeans.core.TimeableEventQueue.quantum=360000 -Dpolyglot.js.nashorn-compat=true -Dsun.misc.URLClassPath.disableJarChecking=true -Djdk.attach.allowAttachSelf=true -Dorg.openide.util.ImageUtilities.level=950 --add-exports=java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports=java.desktop/sun.swing=ALL-UNNAMED --add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -XX:+IgnoreUnrecognizedVMOptions -Dnetbeans.logger.console=true -Dfile.encoding=UTF-8 -Dswing.metalTheme=steel -Dswing.boldMetal=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/a00664975/.visualvm/2.1.10/var/log/heapdump.hprof -Djava.security.manager=allow -Dswing.metalTheme=steel -Dswing.boldMetal=true Compiler: HotSpot 64-Bit Tiered Compilers Heap memory usage: initial 24,0MB maximum 16384,0MB Non heap memory usage: initial 7,3MB maximum -1b Garbage collector: G1 Young Generation (Collections=10 Total time spent=0s) Garbage collector: G1 Old Generation (Collections=0 Total time spent=0s) Classes: loaded=6943 total loaded=6943 unloaded 0 INFO [org.netbeans.core.ui.warmup.DiagnosticTask]: Total memory 16 774 262 784 INFO [null]: Total physical memory 16 774 262 784 ```

Screenshots

jconsole

jmc

visualvm

Desktop (please complete the following information):

Additional context

I'm running VisualVM in a Debian 12 WSL2 VM:

$ wsl --version
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.19045.4780

I'm also using PuTTY to connect to the VM and VcXsrv 1.20.14.0 as my X server

0x6675636b796f75676974687562 commented 1 month ago

Apparently, the issue has something to do with VisualVM proxy settings.

When I switched the connection method to "direct", all connection issues were immediately resolved. Yet, I'm curious why VisualVM tries to use any proxies when connecting to 127.0.0.1 and/or attaching to a PID.

So, to reproduce the issue, one might set the proxy host to some nonexistent address, and add 127.0.0.1 to non-proxy hosts.