Closed Bug 351609 Opened 19 years ago Closed 19 years ago

PR_UnloadLibrary always calls NSUnLinkModule on lib->dlh on Mac OS X.

Categories

(NSPR :: NSPR, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(1 file)

On Mac OS X, PRLibrary has several fields: CFragConnectionID connection; CFBundleRef bundle; CFMutableDictionaryRef wrappers; const struct mach_header* image; NSModule dlh; because we support loading several kinds of shared libraries. Only one of these fields is non-NULL. In PR_UnloadLibrary, we always call NSUnLinkModule on lib->dlh: result = NSUnLinkModule(lib->dlh, NSUNLINKMODULE_OPTION_NONE) ? 0 : -1; probably because lib->dlh is the first supported or "primary" kind of shared library. If lib->dlh is NULL, this call causes 'result' to be set to -1, and eventually causes PR_UnloadLibrary to fail, even though the right kind of shared library (lib->connection, lib->bundle, lib->wrappers, or lib->image) is successfully unloaded.
Attached patch Proposed patchSplinter Review
The fix is to test lib->dlh for non-NULL, just like we test lib->connection, lib->bundle, and lib->wrappers for non-NULL later in the PR_UnloadLibrary function.
Attachment #237026 - Flags: review?(mark)
Comment on attachment 237026 [details] [diff] [review] Proposed patch Looks good. The description in comment 0 is slightly misleading, but the patch is fine. (When you say "only one of these fields is non-NULL," it's not quite true: wrappers and connection are set together. Also, lib->image cannot be unloaded.)
Attachment #237026 - Flags: review?(mark) → review+
You're right, Mark. Thanks for the code review. I checked in the patch on the NSPR trunk (NSPR 4.7) and the NSPRPUB_PRE_4_2_CLIENT_BRANCH (Mozilla 1.9 alpha). Checking in prlink.c; /cvsroot/mozilla/nsprpub/pr/src/linking/prlink.c,v <-- prlink.c new revision: 3.92; previous revision: 3.91 done Checking in prlink.c; /cvsroot/mozilla/nsprpub/pr/src/linking/prlink.c,v <-- prlink.c new revision: 3.51.2.37; previous revision: 3.51.2.36 done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.7
I checked in the patch on the NSPR_4_6_BRANCH (NSPR 4.6.4). Checking in prlink.c; /cvsroot/mozilla/nsprpub/pr/src/linking/prlink.c,v <-- prlink.c new revision: 3.81.2.5; previous revision: 3.81.2.4 done
Target Milestone: 4.7 → 4.6.4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: