Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#238 closed defect (invalid)

Exception handler not working in forked child

Reported by: ydario Owned by: bird
Priority: normal Milestone: libc-0.6.4
Component: libc-backend Version:
Severity: normal Keywords: not-a-bug


When a process executes a fork(), the registered exception handlers are not working in child process. In my case, I registered EXCEPTQ 7.0 handler to dump exceptions to disk.

Registering exception handler in fork()ed code, allows testcase code to dump the exception.

Attachments (2)

exceptq.c (824 bytes) - added by ydario 9 years ago.
exceptq.h (5.6 KB) - added by ydario 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by ydario

Changed 9 years ago by ydario

comment:1 Changed 9 years ago by ydario

Link to R Walsh/S Levine exception handler (with source):

comment:2 Changed 9 years ago by bird

(In [3673]) Testcase for ticket 238. references #238.

comment:3 Changed 9 years ago by bird

  • Keywords not-a-bug added
  • Resolution set to invalid
  • Status changed from new to closed

There is nothing wrong in LIBC. The problem is that you are using DosLoadModule? to load the exception handler code into the process. LIBC doesn't know about this can won't reload the module in the child address space, so the exception handler chain in the child will contain an invalid entry - bang.

comment:4 Changed 9 years ago by ydario

Is there a workaround for child processes? e.g. some way to detect forking and reinstall the handler?

It seems a static library for exceptq could do the trick, but it will be still nice to use the DLL approach (e.g. licenses not compatible, or other...)

comment:5 Changed 9 years ago by bird

This has nothing to do with reinstalling the handler, it is still there only the code it points to isn't there. You have to make sure the DLL is loaded into the child process one way or another.

The fix is to add


before including os2emx.h. An alternative is to replace DosLoadModule? with dlopen.

Note: See TracTickets for help on using tickets.