Skip to content

Dangerous linking options #454

Open
Open
@rdoeffinger

Description

@rdoeffinger

(note: resolving #205 might avoid the issue in many cases in practice as well, but might not fully resolve it in case of different build configs)
When loading libz.so.1 with dlopen and RTLD_LOCAL it can happen that you end up with mysterious crashes.
The reason is that your library is run inside a program that ALSO uses zlib, but a different version and does not hide the symbols (loads it RTLD_GLOBAL, depends on it, ...).
The end result is that deflateInit2_ when calling deflateReset() ends up calling deflateReset from that INCOMPATIBLE version of zlib.
The normal solution to that is to link with -Wl,-Bsymbolic.
Alternatively (e.g. if one wanted to avoid depending on non-generic compiler options) it would be possible to forbid calling any exported functions from zlib code itself. This will be more difficult to do though, I do not know if there are any other pieces of code with this same issue.

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