Open
Bug 96122
Opened 23 years ago
Updated 2 years ago
memory leak in prlink.c
Categories
(NSPR :: NSPR, defect)
Tracking
(Not tracked)
NEW
Future
People
(Reporter: jeff, Unassigned)
References
Details
(Keywords: memory-leak)
Attachments
(1 file, 1 obsolete file)
427 bytes,
patch
|
Details | Diff | Splinter Review |
in nsprpub/pr/src/linking/prlink.c, the routine _PR_ShutdownLinker()
is #ifdef'd WIN16. The cleanup there is also applicable to WIN32.
consider changing:
<#if defined(WIN16)
>#if defined(WIN16) || defined(WIN32)
also, make the same change in prinit.c around the call to this
function.
you may also want to consider adding the following to
the bottom of this function:
if (_pr_currentLibPath)
{
PR_Free(_pr_currentLibPath);
_pr_currentLibPath = NULL;
}
this is a static leak rather than a per-connection leak.
Comment 1•23 years ago
|
||
More memory leak goodness thanks jeff.
Comment 2•23 years ago
|
||
I agree that the cleanup in _PR_ShutdownLinker() is also applicable to other platforms. However, I don't think it is NSPR's responsibility to unload the DLLs for the application. Any DLLs loaded by the application via PR_LoadLibrary should be unloaded by the application via PR_UnloadLibrary. Therefore, I left the original _PR_ShutdownLinker() as is (still ifdef's WIN16) and wrote a new implementation that destroys the static data created by NSPR. This patch is not complete because I haven't figured out how to destroy pr_exe_loadmap. While I was at it, I also fixed the problem that the allocation and free routines for _pr_currentLibPath and lib->name were mismatched. They are now allocated by either malloc() or strdup() and freed by free().
Comment 3•23 years ago
|
||
Comment on attachment 62906 [details] [diff] [review] Proposed patch. Incomplete (pr_exe_loadmap is not destroyed) Checked in this patch into the tip of NSPR.
Comment 4•23 years ago
|
||
I just wanted to note that this bug is not fixed until pr_exe_loadmap has been dealt with.
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → Future
Updated•23 years ago
|
OS: Windows 2000 → All
Hardware: PC → All
Comment 5•23 years ago
|
||
clearing keywords to reflect that the patch is in.
Attachment #62906 -
Attachment is obsolete: true
Updated•18 years ago
|
QA Contact: wtchang → nspr
Comment 6•16 years ago
|
||
In comment 2, I didn't write down why it's hard to destroy pr_exe_loadmap. Now I don't remember what I thought the issues were. I just studied all the code that uses pr_exe_loadmap. The only issue I found is that PR_LoadStaticLibrary may reference pr_exe_loadmap->dlh: http://mxr.mozilla.org/nspr/source/nsprpub/pr/src/linking/prlink.c#1613 1611 lm->name = strdup(name); 1612 lm->refCount = 1; 1613 lm->dlh = pr_exe_loadmap ? pr_exe_loadmap->dlh : 0; <=== REFERENCE 1614 lm->staticTable = slt; 1615 lm->next = pr_loadmap; 1616 pr_loadmap = lm; So we can destroy pr_exe_loadmap only if no lm on pr_loadmap has lm->staticTable != NULL and lm->dlh == pr_exe_loadmap->dlh.
Proposed patch to correctly destroy pr_exe_loadmap in PR_ShutdownLinker() (nspr/pr/src/linking/prlink.c)
I found this old bug, and I have a proposed patch that might destroy pr_exe_load_map correctly. Call PR_UnloadLibrary(pr_exe_loadmap); and then set it to NULL p_exe_load_map = NULL; This should bypass the reference in PR_LoadStaticLibrary since it checks for NULL before de-referencing pr_exe_loadmap
Comment 9•6 years ago
|
||
hduston, IIUC Wan-Teh's comment 6 means: Unconditionally destroying pr_exe_loadmap, like suggested in your patch, shouldn't be done. Rather, you'd have to verify the conditions described in comment 6 are false, and only then destroy. If true, you'd have to allow it to leak.
Comment 10•2 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months and this bug has priority 'P2'.
:KaiE, could you have a look please?
For more information, please visit auto_nag documentation.
Assignee: wtc → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(kaie)
Updated•2 years ago
|
Flags: needinfo?(kaie)
Priority: P2 → --
Updated•2 years ago
|
Severity: minor → S4
You need to log in
before you can comment on or make changes to this bug.
Description
•