Multithreaded proxy detection crashes the JVM

Bug #885195 reported by Michael Stringer
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
openjdk-6 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Calling ProxySelector.select on multiple threads with java.net.useSystemProxies can cause the VM to randomly crash or output dbus assertion errors. This only affects Linux and has only been reported by our users since Ubuntu 11.10 was released (although there is a similar bug in Glassfish - http://java.net/jira/browse/GLASSFISH-12213).

If the application crashes then it will be in either [libdbus-1.so.3] dbus_watch_handle or [libc.so.6] _IO_str_pbackfail. The dbus error outputted when it fails but doesn't crash the VM is:
(process:23565): GConf-CRITICAL **: gconf_engine_get_fuller: assertion `err == NULL || *err != NULL' failed

Adding a synchronized block to the select call solves the problem in our application but no calls to the Java standard library should cause a VM crash.

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: openjdk-6-jre-headless 6b23~pre10-0ubuntu5
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic 3.0.4
Uname: Linux 3.0.0-12-generic i686
ApportVersion: 1.23-0ubuntu4
Architecture: i386
Date: Wed Nov 2 12:52:39 2011
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110427.1)
ProcEnviron:
 LANGUAGE=en_GB:en
 PATH=(custom, user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: openjdk-6
UpgradeStatus: Upgraded to oneiric on 2011-10-14 (19 days ago)

Revision history for this message
Michael Stringer (stringbean) wrote :
Revision history for this message
Michael Stringer (stringbean) wrote :
Revision history for this message
Michael Stringer (stringbean) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openjdk-6 (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bigaret (sebastien-bigaret-f) wrote :

Attached is a simple wrapper that can be used to replace the default proxy selector, to eliminate the random crashes.

How to use: simply replace the default proxy selector as soon as possible in your application code:

    ProxySelector defaultProxySelector = ProxySelector.getDefault();
    if (defaultProxySelector!=null)
        ProxySelector.setDefault(new ProxySelectorWrapper(defaultProxySelector));

Details: making the select() method synchronized eliminates the possibility to concurrently access the MT-unsafe 'gconf_client' which is used in the native method sun.net.spi.DefaultProxySelector.getSystemProxy() (which in turn is called by DefaultProxySelector.select() when property java.net.useSystemProxies is set to true).

See:
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7188755
- http://mail.openjdk.java.net/pipermail/jdk7u-dev/2012-August/003911.html
- openjdk/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
- openjdk/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java

Revision history for this message
Sebastien Bigaret (sebastien-bigaret-f) wrote :

I forgot to explicitely mention that this is NOT a bug fix, but a workaround to avoid triggering the bug until it is fixed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.