-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
c-hyper: fix two memory leaks in Curl_http
.
#11729
Conversation
A request created with `hyper_request_new` must be consumed by either `hyper_clientconn_send` or `hyper_request_free`. This is not terrifically clear from the hyper docs -- `hyper_request_free` is documented only with "Free an HTTP request if not going to send it on a client" -- but a perusal of the hyper code confirms it. This commit adds a `hyper_request_free` to the `error:` path in `Curl_http` so that the request is consumed when an error occurs after the request is created but before it is sent. Fixes the first memory leak reported by Valgrind in curl#10803.
There is a `hyper_clientconn_free` call on the happy path, but not one on the error path. This commit adds one. Fixes the second memory leak reported by Valgrind in curl#10803.
Because the leaks have been fixed.
Curl_http
.Curl_http
.
@@ -119,12 +119,6 @@ problems may have been fixed or changed somewhat since this was written. | |||
|
|||
1. HTTP | |||
|
|||
1.1 hyper memory-leaks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to renumber the two entries below and also delete/renumber in the index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, the script that converts that to show on the website handles gaps just fine. We prefer gaps than having to reorder every time we add/remove.
Thanks! |
@bagder: In every other GitHub project I've contributed to, accepted PRs end up in the "merged" state, and the "closed" state is used for rejected PRs. But you're doing it in a different way which leaves accepted PRs marked as "Closed with unmerged commits". There is also a message above "bagder closed this in c61dd5f", which refers to a single commit but there were three commits in this PR. Is there a reason for this? As a newbie to the project it surprised me and confused me a bit. Perhaps you don't want merges in the commit history? If that's the case you can allow rebase merging. Or is there another reason? |
That's right. Most PRs with pieced changes are condensed into a single commit. The commit message is always amended to meet our guidelines then rebased on upstream/master (upstream: this repo). The author is preserved and the committer name is the person pushing the commit (another guideline). The committer name is not GitHub. |
The commit that gets mentioned in the PR is the one that uses the We do this to maintain commit message style, squashed commits and linear history. The commits are done with the command line and GitHub offers no better way to signal this in the PR. I keep pointing this out to them and hope that one day we get a |
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
A request created with `hyper_request_new` must be consumed by either `hyper_clientconn_send` or `hyper_request_free`. This is not terrifically clear from the hyper docs -- `hyper_request_free` is documented only with "Free an HTTP request if not going to send it on a client" -- but a perusal of the hyper code confirms it. This commit adds a `hyper_request_free` to the `error:` path in `Curl_http` so that the request is consumed when an error occurs after the request is created but before it is sent. Fixes the first memory leak reported by Valgrind in curl#10803. Closes curl#11729
There is a `hyper_clientconn_free` call on the happy path, but not one on the error path. This commit adds one. Fixes the second memory leak reported by Valgrind in curl#10803. Fixes curl#10803 Closes curl#11729
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl.
Curl had two memory leaks in its usage of the hyper C API. I fixed these in curl/curl#11729. While fixing these, as a hyper newbie I found a lack of clarity in the docs about where the responsibilities lie for allocating and deallocating things. I had to repeatedly look at the `Box::into_raw`/`Box::from_raw` calls in the C API code to properly understand things. This commit extends the docs. - For all functions that allocate things, make it clear which functions can be used to subsequently deallocate. - For all functions that free things, make it clear if there are (or aren't) other functions that may have otherwise consumed the thing, thus removing the need for explicit freeing. - Clarify some functions that consume things. This is the documentation I wished was present when I was fixing the leaks in curl. Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
These commits fix the memory leaks in #10803.