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-10244] Compression overlay #52644
Comments
Cc: @@moiseev |
Thanks for reporting this, @benrimmington! I am not entirely sure bugs like this belong here, though. In general problems with the Apple APIs should be reported via https://bugreport.apple.com/ For a better discoverability it might make sense to create a bug here and link to a radar filed at the URL above. |
Oh.. Just to make sure, I contacted the Compression team and sent them your suggestions, so you don't need to file radars for this particular issue. |
@@moiseev, thanks for contacting the team. I've updated the description of this issue, but I can also file radars if needed. The overlay is already in the Swift 5.1 branch, so it might be too late to fix anything. |
Fixed by Eric Bainville in:
|
Additional Detail from JIRA
md5: 92f37e58a29d0ef9552d7c726fa159a9
Issue Description:
An overlay for the Compression framework was added in apple/swift#21939 (for Swift 5.1).
The internal
compression_stream
initializer is allocating empty buffers usingUnsafeMutablePointer<UInt8>.allocate(capacity:0)
but these are not deallocated later. The compression_stream_init function will resetdst_ptr
andsrc_ptr
tonil
. I suspect that the overlay will leak minimum-sized allocations.Can the
dst_ptr
andsrc_ptr
be changed to__nullable
in the <compression.h> file?Or can the internal initializer use
UnsafeMutablePointer<UInt8>(bitPattern: -1)!
instead?The framework uses typed
uint8_t *
buffer pointers, but Foundation.Data prefers rawvoid *
buffer pointers. The overlay appears to be using deprecated withUnsafeBytes and withUnsafeMutableBytes methods.Can the
dst_ptr
andsrc_ptr
be changed tovoid *
andconst void *
in the <compression.h> file?Or can the overlay use non-deprecated withUnsafeBytes and withUnsafeMutableBytes methods, followed by some kind of rebinding to typed pointers?
The overlay also adds a
FilterError
enum. Some of its case names have redundant parts (i.e. thefilter
prefixes andError
suffixes). Some of the documentation comments in the overlay are referring to older case names./// - Throws: `FilterError.StreamInitError` if stream initialization failed
/// - Throws: `FilterError.StreamProcessError` if an error occurs during processing
The availability of C and Swift APIs is different:
__API_AVAILABLE(macos(10.11), ios(9.0))
in the <compression.h> file.@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
in the overlay.Should the <compression.h> file also have tvOS and watchOS version numbers?
Should the overlay use version 9999 placeholders?
Could the <compression.h> file use attributes for ClangImporter, rather than adding wrappers to the overlay?
attribute((swift_name("...")))
for the enums and their cases.attribute((enum_extensibility(closed)))
for thecompression_stream_operation
andcompression_status
enums.Deprecated typealiases, etc. in the overlay for source compatibility.
If the overlay imports Foundation, does that mean that Foundation can't import Compression later, due to a circular dependency? For example, SE-0088 was unable to use
Foundation.Date
due to "layering restrictions".Should the
InputFilter
andOutputFilter
classes be moved to Foundation, possibly as subclasses of the abstract Stream class?Or could the overlay use a generic requirement similar to MutableDataProtocol?
The text was updated successfully, but these errors were encountered: