The primordial thread is attached again in _PR_CleanupIO in PR_Cleanup.

RESOLVED FIXED in 4.7.1

Status

defect
RESOLVED FIXED
16 years ago
11 years ago

People

(Reporter: wtc, Assigned: wtc)

Tracking

4.7.1
x86
Windows XP

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Assignee

Description

16 years ago
This bug is in the NSPR classic code base.  I haven't
looked at the pthread version to see if it also has
this bug.

In PR_Cleanup, we first set the current thread to NULL
(in _PR_MD_EXIT_THREAD) and then call _PR_CleanupIO.
But _PR_CleanupIO calls PR_Lock, which attaches the
current thread again.  Here is the stack trace:

=>[1] _PRI_AttachThread(type = RW_WRITER, priority = PR_PRIORITY_NORMAL, stack =
 (nil), flags = 0), line 1453 in "pruthr.c"
  [2] _pr_current_thread_tls(), line 359 in "solaris.c"
  [3] PR_Lock(lock = 0x24f50), line 224 in "prulock.c"
  [4] _PR_Putfd(fd = 0x22778), line 173 in "prfdcach.c"
  [5] PR_FreeFileDesc(fd = 0x22778), line 149 in "prio.c"
  [6] _PR_CleanupIO(), line 80 in "prio.c"
  [7] PR_Cleanup(), line 453 in "prinit.c"
  [8] main(argc = 1, argv = 0xffbef90c), line 409 in "foreign.c"

Seems that we need to move the _PR_MD_EXIT_THREAD call near the
end of the PR_Cleanup call.
Assignee

Comment 1

16 years ago
*** Bug 222709 has been marked as a duplicate of this bug. ***

Comment 2

15 years ago
PR_Cleanup must be slightly reordered: threads must be cleaned-up *AFTER*
CleanupIO(), as CleanupIO() does a _pr_current_thread_tls.

Comment 3

15 years ago
Sorry for the delay. We have been successfully using the proposed patch (for
NSPR version 4.3) since beginning of March.
QA Contact: wtchang → nspr
Assignee

Updated

11 years ago
Status: NEW → ASSIGNED
Target Milestone: --- → 4.7.1
Assignee

Comment 4

11 years ago
To fix the memory leaks in PR_Cleanup, we must move the _PR_CleanupIO call
before the _PR_MD_EXIT_THREAD(me) call.  I moved _PR_CleanupIO (and
_PR_CleanupNet) further up, before where we start to clean up the current thread.

I checked in this patch (a variant of Gerard's patch) on the NSPR trunk (NSPR 4.7.1).
Checking in prinit.c;
/cvsroot/mozilla/nsprpub/pr/src/misc/prinit.c,v  <--  prinit.c
new revision: 3.49; previous revision: 3.48
done
Attachment #154971 - Attachment is obsolete: true
Assignee

Updated

11 years ago
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.