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

RESOLVED FIXED in 4.6.4

Status

NSPR
NSPR
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: Wan-Teh Chang, Assigned: Wan-Teh Chang)

Tracking

4.6.4
PowerPC
Mac OS X

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

11 years ago
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.
(Assignee)

Comment 1

11 years ago
Created attachment 237026 [details] [diff] [review]
Proposed patch

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 2

11 years ago
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+
(Assignee)

Comment 3

11 years ago
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
Last Resolved: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.7
(Assignee)

Comment 4

11 years ago
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.