Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes memory leak in RSA-Signer #260

Merged
merged 2 commits into from
Sep 9, 2018
Merged

Conversation

Fahrenholz
Copy link
Contributor

A SSL-Key-resource was created and never freed, thus creating a memory leak. This pull request fixes it by freeing the resource.

@@ -52,7 +55,7 @@
*
* @throws InvalidArgumentException
*/
private function validateKey($key): void
protected function validateKey($key): void
Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this to private

Copy link
Sponsor Collaborator

@Ocramius Ocramius Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop 235d487 to achieve that

@Fahrenholz
Copy link
Contributor Author

@Ocramius Changes done. I'ld still change this method from private to protected, thus making overloading and using it in a child-class possible.

@Ocramius
Copy link
Sponsor Collaborator

This class is not designed for inheritance: another interface implementation is the correct approach here

Copy link
Owner

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fahrenholz thanks for your patch. I have a question, though. Shouldn't we call openssl_pkey_free() after creating the signature with the private key as well?

@Fahrenholz
Copy link
Contributor Author

Fahrenholz commented Aug 24, 2018

@lcobucci Hm, yes, that would be good as it creates a new resource. I updated my PR.

@lcobucci
Copy link
Owner

lcobucci commented Sep 9, 2018

@Fahrenholz sorry about my delay, I have just one more question =)

Do you know of any reliable way to test this?

@lcobucci lcobucci added this to the 3.3.0 milestone Sep 9, 2018
@lcobucci lcobucci self-assigned this Sep 9, 2018
@lcobucci
Copy link
Owner

lcobucci commented Sep 9, 2018

@Fahrenholz 🚢

We can try to add tests in another PR, I'll be backporting this to 3.3 now. Thanks for your help!

lcobucci added a commit that referenced this pull request Sep 9, 2018
@Fahrenholz
Copy link
Contributor Author

@lcobucci : I don't really know of a way to test it unfortunately. I can tell you how I found out: We had a long running process, with reactPHP as a server. After every request, we verified the included JWT in order to authenticate the user. And so after every 100 requests we saw that the PHP process had slightly grown, eventually getting so big every one or two weeks that it killed the container.

Maybe a strategy would be to performance test it with jmeter or gatling.

@Ocramius
Copy link
Sponsor Collaborator

Ocramius commented Sep 9, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants