Skip to content

X509_PUBKEY_set(): Fix memory leak#11038

Merged
openssl-machine merged 1 commit intoopenssl:masterfrom
levitte:fix-X509_PUBKEY_set-memleak-20200107
Feb 11, 2020
Merged

X509_PUBKEY_set(): Fix memory leak#11038
openssl-machine merged 1 commit intoopenssl:masterfrom
levitte:fix-X509_PUBKEY_set-memleak-20200107

Conversation

@levitte
Copy link
Member

@levitte levitte commented Feb 7, 2020

With the provided method of creating the new X509_PUBKEY, an extra
EVP_PKEY is created and needs to be properly cleaned away.

(note: we could choose to keep it just as well, but there are
consequences, explained in a comment in the code)

@levitte levitte added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Feb 7, 2020
@levitte levitte force-pushed the fix-X509_PUBKEY_set-memleak-20200107 branch from f67f950 to 2cb71e2 Compare February 7, 2020 10:04
@levitte
Copy link
Member Author

levitte commented Feb 10, 2020

Ping! This should be low hanging fruit

Copy link
Member

@beldmit beldmit left a comment

Choose a reason for hiding this comment

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

I hope the comment provides enough context.

@beldmit beldmit added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Feb 10, 2020
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Feb 11, 2020
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

With the provided method of creating the new X509_PUBKEY, an extra
EVP_PKEY is created and needs to be properly cleaned away.

(note: we could choose to keep it just as well, but there are
consequences, explained in a comment in the code)

Reviewed-by: Dmitry Belyavskiy <[email protected]>
(Merged from openssl#11038)
@levitte levitte force-pushed the fix-X509_PUBKEY_set-memleak-20200107 branch from 2cb71e2 to a076951 Compare February 11, 2020 12:11
@openssl-machine openssl-machine merged commit a076951 into openssl:master Feb 11, 2020
@levitte
Copy link
Member Author

levitte commented Feb 11, 2020

Merged.

a076951 X509_PUBKEY_set(): Fix memory leak

@levitte
Copy link
Member Author

levitte commented Feb 11, 2020

Thanks @DDvO, for showing by example how to get these merges properly visible on github

@DDvO
Copy link
Contributor

DDvO commented Feb 11, 2020

Thanks @DDvO, for showing by example how to get these merges properly visible on github

Oh, why do you think I've done that? At least I did not do consciously.
Maybe my wife did that, but in this case the button would have been pink instead 😉
I suppose it's just a new GitHub feature that I happened to trigger first?

@mattcaswell
Copy link
Member

Oh, why do you think I've done that? At least I did not do consciously.
Maybe my wife did that, but in this case the button would have been pink instead wink
I suppose it's just a new GitHub feature that I happened to trigger first?

Normally when we push a github PR, we have to rebase it first. Therefore github does not recognise that we've actually pushed it, and always thinks that we've closed the PR unmerged. By force-pushing the PR to github first (as you did in #10667) and then pushing to master, github is recognising that the PR has been merged, closes it automatically and shows the "Merged" icon.

@levitte
Copy link
Member Author

levitte commented Feb 11, 2020

More so, addrev rewrites history, meaning that the commits that end up in master diverge from the PR branch, but force-pushing after addrev makes it look nicer.

@beldmit
Copy link
Member

beldmit commented Feb 11, 2020

May I ask @DDvO to incorporate the brilliant changes he made to the workflow @mspncp has provided?

@DDvO
Copy link
Contributor

DDvO commented Feb 15, 2020

Thanks @mattcaswell, @levitte, and @beldmit for your affirming and well explaining further comments that you gave 4 days ago, which I did not notice until now.

May I ask @DDvO to incorporate the brilliant changes he made to the workflow @mspncp has provided?

@beldmit did you mean by 'incorporate' to reflect the workflow enhancements in ghmerge, i.e., as a further tweak in openssl/tools#59 ?
If so, I don't think this is possible in general because it requires modifying the commits in the contributor's repo.

@beldmit
Copy link
Member

beldmit commented Feb 16, 2020

@beldmit did you mean by 'incorporate' to reflect the workflow enhancements in ghmerge, i.e., as a further tweak in openssl/tools#59 ?
If so, I don't think this is possible in general because it requires modifying the commits in the contributor's repo.

I'm just interested in a list of github commands.
Now I use these options:

git fetch --all && git checkout master && git pull
git branch -D pr-xxxx
git checkout pr-xxxx
git rebase -i master
addrev --prnum=xxxx @mattcaswell @beldmit master..HEAD
git push origin HEAD:master

And have to close the PR manually. Your workflow, as I understand, is better.

@DDvO
Copy link
Contributor

DDvO commented Feb 17, 2020

@beldmit, your workflow would get adapted to something like the following
in order to lead GitHub to recognize that the branch has been merged.
Note that the push to pr-xxxx.orig is optional for keeping a copy of the branch before it is squashed, which has been discussed with @bernd-edlinger - see #10620 (comment).

git fetch --all && git checkout master && git pull
git branch -D pr-xxxx
git checkout pr-xxxx
git checkout -b pr-xxxx.orig && git push -u <remote>  pr-xxxx.orig && git checkout pr-xxxx     # do a backup
git rebase -i [--autosquash] master                     # rebase and do all squashing you want to do
addrev --prnum=xxxx @mattcaswell @beldmit master..HEAD
git push -f                                             # update the online branch of the PR
git push origin HEAD:master

@levitte levitte deleted the fix-X509_PUBKEY_set-memleak-20200107 branch February 17, 2020 11:26
@DDvO
Copy link
Contributor

DDvO commented Aug 12, 2020

BTW, I recently again came across the topic of marking successful merge of a PR by the purple "Merged" GitHub symbol.

I've tried out on #12615 an enhancement of the procedure mentioned above, using the latest version of ghmerge.
In the shell that I used for editing that PR I called

git fetch upstream; git rebase -i --autosquash upstream/master
addrev [email protected] 12615 mattcaswell

which already added to the respective commit message(s):

    Reviewed-by: Matt Caswell <[email protected]>
    (Merged from https://github.com/openssl/openssl/pull/12615)

Then I force-pushed to the PR (which some committers consider unclean because strictly speaking this overwrites the approved version, but just by a likely rebase, possibly squashing, and meta info addition):

git push --force-with-lease

Then (in a different shell where I do the merge commands) I entered as usual:

ghmerge --nobuild [email protected] 12615 mattcaswell

which did not further modify the commits because its internal addrev call realized that the meta info was already present.
So this rather simple merge procedure had the desired effect of producing the purple icon 🚀

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

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants