#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)
Change History (7)
by , 14 years ago
by , 14 years ago
comment:1 by , 14 years ago
comment:3 by , 14 years ago
Keywords: | not-a-bug added |
---|---|
Resolution: | → invalid |
Status: | new → 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 by , 14 years ago
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 by , 14 years ago
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.
Link to R Walsh/S Levine exception handler (with source):
http://hobbes.nmsu.edu/download/pub/os2/dev/util/exceptq70-dev.zip