Skip to content

Avoid holding a GlobalRef to ALPN selector#735

Merged
prbprbprb merged 4 commits into
google:masterfrom
kruton:fix-global-ref-leak
Oct 24, 2019
Merged

Avoid holding a GlobalRef to ALPN selector#735
prbprbprb merged 4 commits into
google:masterfrom
kruton:fix-global-ref-leak

Conversation

@kruton

@kruton kruton commented Oct 23, 2019

Copy link
Copy Markdown
Contributor

The ALPN selector code used to hold a GlobalRef for the callback. This
appeared to make it impossible to discard the ref since there wasn't any
trigger for the AppData to be cleared as there is with the
SSLHandshakeCallbacks. Instead move the management of the reference into
Java and use the same SSLHandshakeCallbacks to manage calling into the
ALPN selector code.

This fixes #711

Just to be as safe as possible, use a ScopedLocalRef instead of trying
to manage the jstring reference manually.
The ALPN selector code used to hold a GlobalRef for the callback. This
appeared to make it impossible to discard the ref since there wasn't any
trigger for the AppData to be cleared as there is with the
SSLHandshakeCallbacks. Instead move the management of the reference into
Java and use the same SSLHandshakeCallbacks to manage calling into the
ALPN selector code.

This fixes google#711
Install linux-libc-dev for BoringSSL requirement to see the Linux
getrandom() syscall information.
@kruton kruton force-pushed the fix-global-ref-leak branch 6 times, most recently from 4a8f698 to c11e1dd Compare October 23, 2019 22:54
This is the current default distribution for Travis-CI.
@sunng87

sunng87 commented Oct 24, 2019

Copy link
Copy Markdown

Tested from my local build, I confirm this patch fixed the memory leak issue! 🎉

@prbprbprb prbprbprb merged commit 83b6365 into google:master Oct 24, 2019
@prbprbprb

Copy link
Copy Markdown
Contributor

Thanks!

@kruton kruton deleted the fix-global-ref-leak branch October 24, 2019 16:31
@sunng87

sunng87 commented Oct 25, 2019

Copy link
Copy Markdown

Thanks! Could you please make a release for this?

@LukeButters

Copy link
Copy Markdown

@sunng87 how did you test this? Did you build it yourself or get the binaries from some place. I would also like to test it.

@sunng87

sunng87 commented Oct 28, 2019

Copy link
Copy Markdown

@LukeButters yes I built kruton's branch from my laptop and installed the snapshot jar to my local maven repo.

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.

Native memory leak introduced between version 1.0.1 and 1.1.0 and remains in the latest release.

4 participants