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

Massive overhaul of mismanaged memory in Engine #220

merged 3 commits into from Feb 8, 2018


None yet
2 participants
Copy link

gwynne commented Feb 8, 2018

See the commit log. No, seriously, see it.

gwynne added some commits Feb 8, 2018

Repairs a huge number of incorrect accesses to memory outside the val…
…id scope of a pointer, as well as a number of very invalid ABI and memory layout assumptions. In the processes, also fixes several bugs, including not allocating enough memory in HTTP header storage, incorrect appending of the trailing \r\n on HTTP headers, several minor memory leaks, failure to allocate enough space for query parameters in a URI when serializing HTTP requests, and HTTP/1.0 request handling.

@gwynne gwynne added this to the 3.0.0 milestone Feb 8, 2018

@gwynne gwynne requested review from tanner0101 and Joannis Feb 8, 2018

Copy link

tanner0101 left a comment

These changes look good. Thanks! I will make sure we stick to using these Swift methods for working with unsafe pointers going forward.

memcpy(buffer.start, defaultHeaders.start, defaultHeadersSize)
let view = ByteBuffer(start: buffer.baseAddress, count: defaultHeadersSize)
let buffer = MutableByteBuffer.allocate(capacity: defaultHeadersSize)
_ = buffer.initialize(from: defaultHeaders)

This comment has been minimized.


tanner0101 Feb 8, 2018


_ = could be avoided with an assert done either after this line or, better, in a generic extension. assertInitialize


// <name>
memcpy(buffer.start.advanced(by: index.nameStartIndex), name.original, name.original.count)
_ = UnsafeMutableBufferPointer(start: buffer.start.advanced(by: index.nameStartIndex), count: name.original.count)

This comment has been minimized.


tanner0101 Feb 8, 2018


this as well could benefit from an asserting extension.

@tanner0101 tanner0101 merged commit d375341 into beta Feb 8, 2018

1 check passed

ci/circleci: linux Your tests passed on CircleCI!

@tanner0101 tanner0101 deleted the bugfix/many-memory-mismanagement-fixes branch Feb 8, 2018

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