JDK-8337512 : Multiple StackOverflowErrors with recursion involving felix URLStreamHandler
  • Type: Bug
  • Component: core-libs
  • Affected Version: 8u411
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2024-07-30
  • Updated: 2024-10-21
  • Resolved: 2024-10-21
Description
BUG TYPE CHOSEN
===============
Code

== Product: Java SE JDK and JRE (856) ==
========================================
Problem Description
===================
PUBLIC PROBLEM DESCRIPTION 
VM.info reports multiple StackOverflowErrors, e.g.

------------  P R O C E S S  ---------------

OutOfMemory and StackOverflow Exception counts:
StackOverflowErrors=53

------------------------------------------------------

and

------------  P R O C E S S  ---------------

OutOfMemory and StackOverflow Exception counts:
StackOverflowErrors=81

------------------------------------------------------

 And we see some NullPointerExceptions being thrown about 1-2 times per second that may be due to corruption caused by the overflows:

Event: 206891.955 Thread 0x00007fd465d1a000 Exception <a 'java/lang/NullPointerException'> (0x00000006aad43828) 
Event: 206892.746 Thread 0x00007fd466274000 Exception <a 'java/lang/NullPointerException'> (0x000000069acff538)
Event: 206894.729 Thread 0x00007fd465d1d000 Exception <a 'java/lang/NullPointerException'> (0x000000066bf5afb8) 
Event: 206895.559 Thread 0x00007fd466274000 Exception <a 'java/lang/NullPointerException'> (0x0000000657a8edd8) 
Event: 206897.807 Thread 0x00007fd465d1c000 Exception <a 'java/lang/NullPointerException'> (0x00000006241c0398)
Event: 206897.934 Thread 0x00007fd4641ed000 Exception <a 'java/lang/NullPointerException'> (0x0000000623b5e320) 
Event: 206898.552 Thread 0x00007fd465d1a000 Exception <a 'java/lang/NullPointerException'> (0x0000000613bd3ee8) 
Event: 206898.952 Thread 0x00007fd46628d800 Exception <a 'java/lang/NullPointerException'> (0x0000000606c494e8) 
Event: 206899.775 Thread 0x00007fd465d1c000 Exception <a 'java/lang/NullPointerException'> (0x00000005f0050fb0)

A review of one thread dump found at least one thread with some recursion:

This segment repeated 59 times:

	at java.net.URL.<init>(URL.java:639)
	at java.net.URL.<init>(URL.java:507)
	at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1340)
	at sun.misc.URLClassPath.getResource(URLClassPath.java:250)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.getDeclaredMethod(Class.java:2128)
	at org.apache.felix.framework.util.SecureAction.getDeclaredMethod(SecureAction.java:849)
	at org.apache.felix.framework.URLHandlers.getFrameworkFromContext(URLHandlers.java:772)
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.getStreamHandlerService(URLHandlersStreamHandlerProxy.java:574)
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:369)

Only 1025 lines were printed out, we don't seem to be seeing the whole stack
We would like a Sustaining analysis of this and other thread dumps.

END PUBLIC PROBLEM DESCRIPTION

Full JDK Versions
-----------------
JDK 8u411

System Configuration
--------------------
RHEL 8


Comments
submitter observing no issues when the Felix URL Stream handler is disabled (via "felix.service.urlhandlers=false" felix property) Closing this out as not an issue
21-10-2024

I'm including here an example stacktrace (using Felix v6.0.3) which is the code leading up to the recursion we see in felix URL stream handler. read from the bottom up, the interesting calls start at "oracle.security.am.plugin.internal.GenericPluginFactory.getPlugin(GenericPluginFactory.java:99)" ***** org.apache.felix.framework.util.SecureAction.getDeclaredMethod(SecureAction.java:850) org.apache.felix.framework.URLHandlers.getFrameworkFromContext(URLHandlers.java:752) org.apache.felix.framework.URLHandlersStreamHandlerProxy.getStreamHandlerService(URLHandlersStreamHandlerProxy.java:574) org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:369) java.net.URL.<init>(URL.java:639) java.net.URL.<init>(URL.java:507) java.net.URL.<init>(URL.java:456) java.net.JarURLConnection.parseSpecs(JarURLConnection.java:175) java.net.JarURLConnection.<init>(JarURLConnection.java:158) com.oracle.classloader.JarURLHandler$Connection.<init>(JarURLHandler.java:141) com.oracle.classloader.JarURLHandler.openConnection(JarURLHandler.java:117) java.net.URL.openConnection(URL.java:1026) weblogic.utils.classloaders.URLSource.<init>(URLSource.java:21) weblogic.osgi.internal.SharedURLBundleSource.<init>(SharedURLBundleSource.java:20) weblogic.osgi.internal.BundleClassFinder.getSource(BundleClassFinder.java:44) weblogic.osgi.internal.BundleClassFinder.getClassSource(BundleClassFinder.java:96) weblogic.utils.classloaders.MultiClassFinder.getClassSource(MultiClassFinder.java:128) weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:1025) weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:990) weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:611) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:543) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:496) java.lang.ClassLoader.loadClass(ClassLoader.java:405) oracle.security.am.common.utilities.classloader.MaskingClassLoader.loadClass(MaskingClassLoader.java:76) java.lang.ClassLoader.loadClass(ClassLoader.java:405) java.lang.ClassLoader.loadClass(ClassLoader.java:351) java.lang.Class.getDeclaredMethods0(Native Method) java.lang.Class.privateGetDeclaredMethods(Class.java:2701) java.lang.Class.getDeclaredMethod(Class.java:2128) org.apache.felix.framework.util.SecureAction.getDeclaredMethod(SecureAction.java:850) org.apache.felix.framework.URLHandlers.getFrameworkFromContext(URLHandlers.java:752) org.apache.felix.framework.URLHandlersStreamHandlerProxy.getStreamHandlerService(URLHandlersStreamHandlerProxy.java:574) org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:369) java.net.URL.<init>(URL.java:639) java.net.URL.<init>(URL.java:507) java.net.URL.<init>(URL.java:456) java.net.JarURLConnection.parseSpecs(JarURLConnection.java:175) java.net.JarURLConnection.<init>(JarURLConnection.java:158) com.oracle.classloader.JarURLHandler$Connection.<init>(JarURLHandler.java:141) com.oracle.classloader.JarURLHandler.openConnection(JarURLHandler.java:117) java.net.URL.openConnection(URL.java:1026) weblogic.utils.classloaders.URLSource.<init>(URLSource.java:21) weblogic.osgi.internal.SharedURLBundleSource.<init>(SharedURLBundleSource.java:20) weblogic.osgi.internal.BundleClassFinder.getSource(BundleClassFinder.java:44) weblogic.osgi.internal.BundleClassFinder.getClassSource(BundleClassFinder.java:96) weblogic.utils.classloaders.MultiClassFinder.getClassSource(MultiClassFinder.java:128) weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:1025) weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:990) weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:611) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:543) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:496) java.lang.ClassLoader.loadClass(ClassLoader.java:405) oracle.security.am.common.utilities.classloader.MaskingClassLoader.loadClass(MaskingClassLoader.java:76) java.lang.ClassLoader.loadClass(ClassLoader.java:405) java.lang.ClassLoader.loadClass(ClassLoader.java:351) java.lang.Class.getDeclaredMethods0(Native Method) java.lang.Class.privateGetDeclaredMethods(Class.java:2701) java.lang.Class.getDeclaredMethod(Class.java:2128) org.apache.felix.framework.util.SecureAction.getDeclaredMethod(SecureAction.java:850) org.apache.felix.framework.URLHandlers.getFrameworkFromContext(URLHandlers.java:752) org.apache.felix.framework.URLHandlersStreamHandlerProxy.getStreamHandlerService(URLHandlersStreamHandlerProxy.java:574) org.apache.felix.framework.URLHandlersStreamHandlerProxy.hashCode(URLHandlersStreamHandlerProxy.java:220) java.net.URL.hashCode(URL.java:927) java.security.CodeSource.hashCode(CodeSource.java:121) java.util.HashMap.hash(HashMap.java:340) java.util.HashMap.get(HashMap.java:558) java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:204) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) weblogic.utils.classloaders.GenericClassLoader.defineClassInternal(GenericClassLoader.java:1113) weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:1046) weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:1038) weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:990) weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:611) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:543) weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:496) java.lang.ClassLoader.loadClass(ClassLoader.java:405) oracle.security.am.common.utilities.classloader.MaskingClassLoader.loadClass(MaskingClassLoader.java:76) java.lang.ClassLoader.loadClass(ClassLoader.java:405) java.lang.ClassLoader.loadClass(ClassLoader.java:351) org.apache.felix.framework.ExtensionManager$ExtensionManagerWiring.getClassByDelegation(ExtensionManager.java:1179) org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1618) org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1548) org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79) org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982) java.lang.ClassLoader.loadClass(ClassLoader.java:351) xxx.OAMPlugin.NAMEREMOVED.initialize(HMKOAuthCustomClaimsPlugin.java:50) oracle.security.am.plugin.internal.GenericPluginFactory.getPlugin(GenericPluginFactory.java:99) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) oracle.security.am.common.policy.common.response.ResponsePluginProvider.getValue(ResponsePluginProvider.java:133) oracle.security.am.common.policy.common.response.ResponseProcessor.processOne(ResponseProcessor.java:377) oracle.security.am.common.policy.common.response.ResponseProcessor.process(ResponseProcessor.java:178)
27-09-2024