Skip to content

Fix classloader leaks in GlobalEventExecutor - #14616

Merged
chrisvest merged 2 commits into
netty:4.1from
chrisvest:4.1-cl-leak-fix
Dec 25, 2024
Merged

chrisvest merged 2 commits into
netty:4.1from
chrisvest:4.1-cl-leak-fix

Conversation

@chrisvest

Copy link
Copy Markdown
Member

Motivation:
If Netty is on a main classpath in a system that creates ephemeral classloaders, e.g. for plug-ins, then we should avoid holding on to those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future, because the stack trace would hold on to class which in turn hold on to class loaders, and it would hold on to an ephemeral classloader if the GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Fixes #14615

Motivation:
If Netty is on a main classpath in a system that creates ephemeral classloaders, e.g. for plug-ins, then we should avoid holding on to those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future, because the stack trace would hold on to class which in turn hold on to class loaders, and it would hold on to an ephemeral classloader if the GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Fixes netty#14615
@franz1981

Copy link
Copy Markdown
Contributor

@gsmet as well :)

@normanmaurer normanmaurer added this to the 4.1.117.Final milestone Dec 23, 2024
@chrisvest
chrisvest merged commit c7de17a into netty:4.1 Dec 25, 2024
@chrisvest
chrisvest deleted the 4.1-cl-leak-fix branch December 25, 2024 18:02
chrisvest added a commit to chrisvest/netty that referenced this pull request Dec 25, 2024
Motivation:
If Netty is on a main classpath in a system that creates ephemeral
classloaders, e.g. for plug-ins, then we should avoid holding on to
those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future,
because the stack trace would hold on to class which in turn hold on to
class loaders, and it would hold on to an ephemeral classloader if the
GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the
Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Fixes netty#14615
chrisvest added a commit to chrisvest/netty that referenced this pull request Dec 25, 2024
Motivation:
If Netty is on a main classpath in a system that creates ephemeral
classloaders, e.g. for plug-ins, then we should avoid holding on to
those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future,
because the stack trace would hold on to class which in turn hold on to
class loaders, and it would hold on to an ephemeral classloader if the
GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the
Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Fixes netty#14615
chrisvest added a commit that referenced this pull request Dec 26, 2024
Motivation:
If Netty is on a main classpath in a system that creates ephemeral
classloaders, e.g. for plug-ins, then we should avoid holding on to
those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future,
because the stack trace would hold on to class which in turn hold on to
class loaders, and it would hold on to an ephemeral classloader if the
GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the
Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Forward port of #14616
chrisvest added a commit that referenced this pull request Dec 26, 2024
Motivation:
If Netty is on a main classpath in a system that creates ephemeral
classloaders, e.g. for plug-ins, then we should avoid holding on to
those ephemeral classloaders.

Modification:
Clear the stack trace in the GlobalEventExecutor termination future,
because the stack trace would hold on to class which in turn hold on to
class loaders, and it would hold on to an ephemeral classloader if the
GEE was first initialized by code in an ephemeral classloader.

Also avoid holding on to context classloaders through the
Thread.inheritedAccessControlContext when starting the GEE thread.

Result:
Classloader leaks should be fix.

Forward port of #14616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GlobalEventExecutor.terminationFailure - classloader leak with plugin-like classloaders

3 participants