Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#76 closed defect (fixed)

libc: fork() failed when using dlopen()

Reported by: froloff Owned by: bird
Priority: normal Milestone: libc-0.6.2
Component: libc-backend Version: 0.6
Severity: normal Keywords: fork() dlopen DosLoadModuleEx
Cc:

Description (last modified by bird)

If process load module dynamically (dlopen) after that fork will fail.

I examine the situation a bit and divide it into 3 cases

  1. process dlopen() module then forking. Child process failed during initial fork processing.
  2. process dlopen() module, dlclose() module then forking. Parent process trapped during fork processing.
  3. process dlopen() module, dlclose() module, dlopen() module again then forking. Parent process goes endless loop in forkParValidateModules() during fork processing.

I'll send testcase and libc logs via email.

Note. I didn't find code deregistering module from modules chain - conj procedure to __libc_ForkRegisterModule().

Attachments (1)

bug_report.zip (27.9 KB ) - added by froloff 19 years ago.

Download all attachments as: .zip

Change History (6)

by froloff, 19 years ago

Attachment: bug_report.zip added

comment:1 by bird, 19 years ago

Component: baselayoutlibc-backend
Description: modified (diff)
Status: newassigned
Version: 0.6

comment:2 by bird, 19 years ago

Description: modified (diff)
Summary: fork() failed when using dlopen()libc: fork() failed when using dlopen()

comment:3 by bird, 18 years ago

Keywords: fork() dlopen DosLoadModuleEx added

I've analysed and fixed the problems.

The first problem (dlopen(); fork();) fails because of recursive execution of the initial fork buffer in forkChlDoFork(). The recursive call occurs when process the DosLoadModuleEx record for the loaded dll. The fix is simply to advance the fork stage before processing the buffer.

The second problem and third problem are cause by missing fork module deregistration when a DLL is unloaded. The fix is to implement this deregistration. This fix will require relinking of DLLs as it includes dll0.s changes.

There is a forth problem here, the sequence fork(); waitpid(); dlopen(); dlclose(); fork(); waitpid(); fails on the last waitpid. This is covered by ticket #114.

comment:4 by bird, 18 years ago

Resolution: fixed
Status: assignedclosed

(In [2786]) Fixed problems with fork() and module loading/unloading. Fixes #76. Fixed atexit() and on_exit() problem with callbacks in unloaded DLLs. Fixes #103.

comment:5 by bird, 18 years ago

(In [2787]) Fixed problems with fork() and module loading/unloading. Fixes #76. Fixed atexit() and on_exit() problem with callbacks in unloaded DLLs. Fixes #103.

Note: See TracTickets for help on using tickets.