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 784: dont crash on huge in-memory bodies #785

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

weissi
Copy link
Contributor

@weissi weissi commented Nov 22, 2024

fixes #784

writeChunks had 3 bugs:

  1. An actually wrong UnsafeMutableTransferBox -> removed that type which should never be created
  2. A loooong future chain (instead of one final promise) -> implemented
  3. Potentially infinite recursion which lead to the crash in AHC crashes with HTTP2 when uploading a big body when channel & delegate live on separate EventLoops #784) -> fixed too

@weissi weissi requested review from Lukasa and dnadoba November 22, 2024 18:08
// Also, we must frequently return to the EventLoop because we may get the pause signal
// from another thread. If we fail to do that promptly, we may balloon our body chunks
// into memory.
allDone.futureResult.eventLoop.execute {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the crucial line (apart from the thread unsafety from UnsafeMutableTransferBox)

@@ -1548,3 +1586,88 @@ private let key = """
oYQsPj00S3/GA9WDapwe81Wl2A==
-----END PRIVATE KEY-----
"""

final class BasicInboundTrafficShapingHandler: ChannelDuplexHandler {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This turned out to not be necessary, but it's a test-only utility which can't hurt I thought :).

@weissi weissi added the 🆕 semver/minor Adds new public API. label Nov 22, 2024
@weissi weissi force-pushed the jw-784 branch 2 times, most recently from adab7a2 to 692483b Compare November 22, 2024 18:21
@weissi weissi force-pushed the jw-784 branch 5 times, most recently from 0afe7d9 to cd29ba9 Compare November 26, 2024 09:52
@Lukasa Lukasa merged commit 2119f0d into swift-server:main Nov 26, 2024
26 checks passed
@weissi weissi deleted the jw-784 branch November 26, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AHC crashes with HTTP2 when uploading a big body when channel & delegate live on separate EventLoops
2 participants