Use RTLD_LAZY for better error reporting on plugin load failures#27
Open
lrhodin wants to merge 1 commit intofree-audio:masterfrom
Open
Use RTLD_LAZY for better error reporting on plugin load failures#27lrhodin wants to merge 1 commit intofree-audio:masterfrom
lrhodin wants to merge 1 commit intofree-audio:masterfrom
Conversation
Changes plugin loading from RTLD_NOW to RTLD_LAZY on Unix systems to provide immediate, clear error messages when plugins have issues. Problem: When plugins have code signing issues, missing dependencies, or other loading problems, RTLD_NOW can cause silent 10+ second hangs on macOS before eventually timing out. This provides no diagnostic information and wastes significant developer time during debugging. Solution: Use RTLD_LAZY (POSIX default) which detects these issues immediately and returns clear error messages like "code signature not valid" or "library not found" within <1 second. Benefits: - Dramatically improved developer experience (hours → minutes debugging) - Immediate, actionable error messages instead of silent hangs - Aligns with POSIX dlopen() default behavior - Matches loading behavior of real-world DAWs and plugin hosts - No breaking changes - existing plugins continue to work - Strict checking still available via test_scan_rtld_now test Technical Details: - Unix systems: Explicitly use RTLD_LAZY | RTLD_LOCAL flags - Non-Unix: No change (uses platform defaults) - All existing tests pass including test_scan_rtld_now Tested with plugins on macOS with both valid and invalid code signatures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes plugin loading from
RTLD_NOWtoRTLD_LAZYon Unix systems to provide immediate,clear error messages when plugins have code signing or dependency issues, rather than silent
hangs.
Motivation
When plugins have issues (code signing problems, missing dependencies, etc.), the current
RTLD_NOWbehavior can cause silent 10+ second hangs on macOS before eventually timingout, providing no diagnostic information.
Current behavior (RTLD_NOW):
$ clap-validator validate unsigned-plugin.clap (no output for 10+ seconds... eventually timeout)New behavior (RTLD_LAZY):
This dramatically improves developer experience during debugging - turning hours of
investigation into minutes.
Changes
File: src/plugin/library.rs
Code diff: ~20 lines (minimal, focused change)
Rationale
RTLD_LAZY detects issues immediately and returns clear error messages, whereas RTLD_NOW can
cause silent hangs when dyld encounters security policy rejections on macOS. This is a
significant developer experience improvement.
Impact: Hours of debugging → Minutes
From dlopen(3) specification:
RTLD_LAZY: Perform lazy binding. Only resolve symbols as the code that references them is
executed. This is the default behavior.
All major plugin hosting environments use lazy loading:
The validator should match this behavior for accurate testing
The existing test_scan_rtld_now test provides strict upfront symbol checking for plugins that
want to ensure all symbols resolve immediately. This PR makes that an opt-in test rather
than the default behavior.
Testing
Tested with:
Results:
Backwards Compatibility
Note: Tested extensively with web-based CLAP plugin using weak-linked frameworks (WebKit,
CoreGraphics). This change enables better support for modern plugin architectures while
improving error reporting for everyone.