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
[SR-6849] Data leaks on Linux in Swift 4.1 #3741
Comments
The base64 decoding seems to be at fault here: changing the initialiser to just init from |
We triaged this bug to the following commit: This is the mega-commit from the changes in High Sierra. In particular, this seems to have changed flags for swift-corelibs-foundation/Foundation/NSData.swift Lines 70 to 76 in 7157437
For example, the It's not clear what the problem is or whether it's directly related, but the options are still being masked together in the Swift codebase which no longer seems to make sense. |
@swift-ci create |
Comment by David Jones (JIRA) I recently tried running Kitura on recent 4.1 and master snapshots and also noticed a leak. Probably the same issue as this (but let me know if you'd like me to raise a separate one). Extract from a valgrind massif report: 93.39% (7,852,969B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->69.76% (5,866,048B) 0x552B7FF: __CFSafelyReallocate (CFBase.c:771)
| ->69.76% (5,866,048B) 0x55589FA: __CFDataGrow (CFData.c:554)
| ->69.76% (5,866,048B) 0x5556F41: CFDataReplaceBytes (CFData.c:639)
| ->69.76% (5,866,048B) 0x5558C1D: CFDataAppendBytes (CFData.c:609)
| ->69.76% (5,866,048B) 0x580576B: Foundation.NSMutableData.append(Swift.UnsafeRawPointer, length: Swift.Int) -> () (NSData.swift:1059)
| ->69.56% (5,849,088B) 0x241742: KituraNet.HTTPServerResponse.(writeToSocketThroughBuffer in _8A9E8F62631F03CCFCED4F4223E40C30)(text: Swift.String) throws -> () (HTTPServerResponse.swift:204)
...etc KituraNet code here is: https://github.com/IBM-Swift/Kitura-net/blob/2.0.1/Sources/KituraNet/HTTP/HTTPServerResponse.swift#L204 |
That looks like a different leak, I think. |
Comment by David Jones (JIRA) Raised SR-6962 for the NSMutableData leak. |
Comment by Mamatha Busi (JIRA) The above PR had a fix for NSData leak where __CFDataGetInfoBit for __kCFDontDeallocate (then equivalent of __CFDataDontDeallocate before PR for High Sierra changes) was set on an ‘if’ condition and it was in turn checked in the __CFDataDeallocate method of CFData. However, with the HighSierra PR 1338 changes now, the value for __CFDataDontDeallocate is hardcoded to 'true'. __CFDataSetDontDeallocate(memory, true); Therefore, in the __CFDataDeallocate method of CFData, deallocation of CFData never happens. This is causing the leak. IMO, conditional check for setting _CFDataDeallocate based on the CFOptionFlags needs to be introduced again. Could you please have a look at my analysis @phausler |
Comment by Mamatha Busi (JIRA) Opened PR-#1455 |
This appears to be fixed. |
Environment
Ubuntu 16.04
Swift version 4.1-dev (LLVM 5b54bd1e96, Clang 03ed64977b, Swift 88a7a55e83)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
md5: 565e16afee84c6e52512f27cc992472d
Issue Description:
The following program fails under ASAN on Linux when using the Swift nightly from January 25:
The output is:
If we want a more helpful stack we can disable ASAN and run under Valgrind:
This just seems like it's a straightforward leak of
CFData
.The text was updated successfully, but these errors were encountered: