Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#238 closed defect (invalid)

Exception handler not working in forked child

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

Description

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 Yuri Dario 13 years ago.
exceptq.h (5.6 KB) - added by Yuri Dario 13 years ago.

Download all attachments as: .zip

Change History (7)

Changed 13 years ago by Yuri Dario

Attachment: exceptq.c added

Changed 13 years ago by Yuri Dario

Attachment: exceptq.h added

comment:1 Changed 13 years ago by Yuri Dario

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

http://hobbes.nmsu.edu/download/pub/os2/dev/util/exceptq70-dev.zip

comment:2 Changed 13 years ago by bird

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

comment:3 Changed 13 years ago by bird

Keywords: not-a-bug added
Resolution: invalid
Status: newclosed

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 13 years ago by Yuri Dario

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 13 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

#define INCL_EXAPIS
#define INCL_EXAPIS_MAPPINGS

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

Note: See TracTickets for help on using tickets.