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

Fix use-after-free in HTTP callbacks #19863

Closed
wants to merge 1 commit into from

Conversation

pranjalssh
Copy link
Contributor

Summary:
In the HTTPClient, callbacks are scheduled on an eventBase. HTTPClient is kept alive using a shared_ptr, but it contains a raw pointer to MemoryPool. This MemoryPool may be freed if Task is aborted earlier, but a callback is executed much later.
We see crashes related to this when the batch cluster is under heavy load.

So the fix here is to keep shared_ptr to MemoryPool isntead of a raw pointer

Differential Revision: D46672533

Summary:
In the HTTPClient, callbacks are scheduled on an eventBase. HTTPClient is kept alive using a shared_ptr, but it contains a raw pointer to MemoryPool. This MemoryPool may be freed if Task is aborted earlier, but a callback is executed much later.
We see crashes related to this when the batch cluster is under heavy load.

So the fix here is to keep shared_ptr to MemoryPool isntead of a raw pointer

Differential Revision: D46672533

fbshipit-source-id: 1675b6f983c98bb66081d0b668588f975f3f2f05
@pranjalssh pranjalssh requested a review from a team as a code owner June 13, 2023 02:56
@facebook-github-bot
Copy link
Collaborator

This pull request was exported from Phabricator. Differential Revision: D46672533

@amitkdutta amitkdutta requested review from spershin and xiaoxmeng June 13, 2023 03:34
@pranjalssh pranjalssh closed this Jun 13, 2023
pranjalssh added a commit to pranjalssh/presto that referenced this pull request Jun 14, 2023
Summary:
In the HTTPClient, callbacks are scheduled on an eventBase. HTTPClient is kept alive using a shared_ptr, but it contains a raw pointer to MemoryPool. This MemoryPool may be freed if Task is aborted earlier, but a callback is executed much later.
We see crashes related to this when the batch cluster is under heavy load.

So the fix here is to keep shared_ptr to MemoryPool isntead of a raw pointer

```
== NO RELEASE NOTE ==
```

Pull Request resolved: prestodb#19865

Reviewed By: xiaoxmeng

Differential Revision: D46674355

Pulled By: pranjalssh

fbshipit-source-id: 9b53deb6357ff87b8e1a992f3205d0ce9d79c05c
pranjalssh added a commit that referenced this pull request Jun 15, 2023
Summary:
In the HTTPClient, callbacks are scheduled on an eventBase. HTTPClient is kept alive using a shared_ptr, but it contains a raw pointer to MemoryPool. This MemoryPool may be freed if Task is aborted earlier, but a callback is executed much later.
We see crashes related to this when the batch cluster is under heavy load.

So the fix here is to keep shared_ptr to MemoryPool isntead of a raw pointer

```
== NO RELEASE NOTE ==
```

Pull Request resolved: #19865

Reviewed By: xiaoxmeng

Differential Revision: D46674355

Pulled By: pranjalssh

fbshipit-source-id: 9b53deb6357ff87b8e1a992f3205d0ce9d79c05c
@wanglinsong wanglinsong mentioned this pull request Jul 27, 2023
28 tasks
wypb pushed a commit to wypb/presto that referenced this pull request Dec 22, 2023
Summary:
In the HTTPClient, callbacks are scheduled on an eventBase. HTTPClient is kept alive using a shared_ptr, but it contains a raw pointer to MemoryPool. This MemoryPool may be freed if Task is aborted earlier, but a callback is executed much later.
We see crashes related to this when the batch cluster is under heavy load.

So the fix here is to keep shared_ptr to MemoryPool isntead of a raw pointer

```
== NO RELEASE NOTE ==
```

Pull Request resolved: prestodb#19865

Reviewed By: xiaoxmeng

Differential Revision: D46674355

Pulled By: pranjalssh

fbshipit-source-id: 9b53deb6357ff87b8e1a992f3205d0ce9d79c05c
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.

2 participants