Closed Bug 40629 Opened 20 years ago Closed 20 years ago

NSPR's /dev/zero fd gets inherited by child processes

Categories

(NSPR :: NSPR, defect, P3)

Sun
Solaris
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(1 file)

Purify reports a file /dev/zero opened in NSPR which 
gets inherited by child processes.

parent:

         FIU: file descriptor 3: "/dev/zero", O_RDWR
         File info: crw-rw-rw-  1 root     sys              0 May
18  1999
         File position: 0
         This file descriptor was allocated from:
               __open         [libc.so.1]
               _open          [libc.so.1]
               open           [libthread.so.1]
               _PR_InitSegs   [prseg.c:23]
               _PR_InitStuff  [prinit.c:164]
               _PR_ImplicitInitialization [prinit.c:214]
               PR_NewRWLock   [prrwlock.c:117]
               readerlock_open [readerlock_nspr.c:7]
               configmsg_init [configmsg.c:341]
               c_main         [serverstart.c:178]
               main           [main_c.c:14]
               _start         [crt1.o]

child:

         FIU: file descriptor 3: <inherited from parent>
         FIU: file descriptor 4: "/dev/zero", O_RDWR
         File info: crw-rw-rw-  1 root     sys              0 May
18  1999
         File position: 0
         This file descriptor was allocated from:
               __open         [libc.so.1]
               _open          [libc.so.1]
               open           [libthread.so.1]
               _PR_InitSegs   [prseg.c:23]
               _PR_InitStuff  [prinit.c:164]
               _PR_ImplicitInitialization [prinit.c:214]
               PR_NewRWLock   [prrwlock.c:117]
               readerlock_open [readerlock_nspr.c:7]
               configmsg_init [configmsg.c:341]
               pop_main       [pop3d.c:364]
               service_start  [service_unix.c:59]
               c_main         [pop3d.c:637]
               main           [main_c.c:14]
               _start         [crt1.o]

grandchild:

         FIU: file descriptor 4: <inherited from parent>
         FIU: file descriptor 5: <inherited from parent>
         FIU: file descriptor 6: "/dev/zero", O_RDWR
         File info: crw-rw-rw-  1 root     sys              0 May
18  1999
         File position: 0
         This file descriptor was allocated from:
               __open         [libc.so.1]
               _open          [libc.so.1]
               open           [libthread.so.1]
               _PR_InitSegs   [prseg.c:23]
               _PR_InitStuff  [prinit.c:164]
               _PR_ImplicitInitialization [prinit.c:214]
               PR_NewRWLock   [prrwlock.c:117]
               readerlock_open [readerlock_nspr.c:7]
               configmsg_init [configmsg.c:341]
               pop_main       [pop3d.c:364]
               service_start  [service_unix.c:59]
               c_main         [pop3d.c:637]
               main           [main_c.c:14]
               _start         [crt1.o]

This /dev/zero fd is only used in classic NSPR to
allocate thread stacks for our user-level threads.
So in the pthreads version, it can be removed.
We should also set the close-on-exec flag of this
fd to prevent it from being inherited by child
processes.
Attached patch Proposed patch.Splinter Review
I checked in the patch on the main trunk.
/cvsroot/mozilla/nsprpub/pr/include/md/_unixos.h, revision 3.27
/cvsroot/mozilla/nsprpub/pr/include/private/primpl.h, revision 3.43
/cvsroot/mozilla/nsprpub/pr/src/memory/prseg.c, revision 3.5
/cvsroot/mozilla/nsprpub/pr/src/md/unix/unix.c, revision 3.36
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.1
You need to log in before you can comment on or make changes to this bug.