Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

dylink's import-only-once strategy precludes certain function overrides #1408

@choksi81

Description

@choksi81

dylink imports libraries only once (see #1318, #1320). Further calls to dylink requesting to import the same library will refer back to the instance that is already imported.

This makes overriding functions in certain libraries impossible. Consider Affix, where we want to override network calls. All libraries that Affix itself imports (or its libraries imports!) cannot be modified later on. Illustrative code snippets:

cachedadvertise.r2py:

dy_import_module_symbols("sockettimeout.repy")

-------

affix_wrapper_lib.repy:

# We require cachedadvertise for some functionality...
dy_import_module_symbols("cachedadvertise.r2py")

# ...and will do our own thing before we link in sockettimeout
override_network_calls_with_custom_functions()
dy_import_module_symbols("sockettimeout.repy")

sockettimeout should use the overridden functions, but that's not the case. This seems to be the root cause of #1407, seash's NAT traversal broken, and is similar to #1366, openconnection not overwritten.

What should we do about this? From my tests, dylinkbehaves as Python does; also, a few libraries must only be imported once (see #1319 for an issue with uniqueid). OTOH, the functionality to re-import / flush / import under a different name would be very useful, think Affix and Security Layers. Let me hear your opinions on this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions