Skip to content

Missing GC.@preserve #71

@c42f

Description

@c42f

One thing I noticed reading the ZipFile source is that there's some places where GC.@preserve should be used to preserve buffers in use by Zlib, but which are currently missing.

This kind of thing can lead to memory corruption if the GC frees the buffer while zlib is using it (and could ultimately lead to things like #66 and #51).

Basically, whenever you take a pointer to a buffer using pointer(), it's important that you explicitly preserve the Julia object which owns that memory, because Julia can't tell this needs to happen on its own. (Really, Base.pointer() should be deprecated and renamed unsafe_convert or at least unsafe_pointer, because dereferencing the value returned from it is unsafe without extra care!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions