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 crash when aws_s3_meta_request has function called on it after completion #217

Merged
merged 4 commits into from
Oct 21, 2022

Conversation

graebm
Copy link
Contributor

@graebm graebm commented Oct 5, 2022

Issue:
If a function was called on a meta-request after it completed, this would lead to a crash (this affected aws_s3_meta_request_increment_read_window(), aws_s3_meta_request_cancel(), and aws_s3_meta_request_pause())

Since these functions might be called from different threads than the thread that completes the meta-request, it would be nearly impossible for a customer to avoid these crashes.

Description of changes:
The reason for the crash was that the meta_request->client pointer would get cleared when the meta-request completed.

To fix this bug, we stop clearing this pointer early, and keepmeta_request->client pointer valid for the lifetime of the meta-request.

We evaluated doing something much more complex (checking state and toying with reference counts before scheduling work on the client) but it seemed finicky and error-prone.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@graebm graebm marked this pull request as ready for review October 7, 2022 21:56
@graebm graebm enabled auto-merge (squash) October 20, 2022 23:59
@graebm graebm merged commit 1850681 into main Oct 21, 2022
@graebm graebm deleted the client-ptr-fix branch October 21, 2022 00:00
grrtrr pushed a commit to grrtrr/aws-c-s3 that referenced this pull request Nov 1, 2022
…mpletion (awslabs#217)

**Issue**:
If a function was called on a meta-request after it completed, this would lead to a crash (this affected `aws_s3_meta_request_increment_read_window()`, `aws_s3_meta_request_cancel()`, and `aws_s3_meta_request_pause()`)

Since these functions might be called from different threads than the thread that completes the meta-request, it would be nearly impossible for a customer to avoid these crashes.

**Description of changes:**
The reason for the crash was that the `meta_request->client` pointer would get cleared when the meta-request completed.

To fix this bug, we stop clearing this pointer early, and keep`meta_request->client` pointer valid for the lifetime of the meta-request.

We evaluated doing something much more complex (checking state and toying with reference counts before scheduling work on the client) but it seemed finicky and error-prone.
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.

2 participants