Subject: | |
From: | |
Reply To: | |
Date: | Mon, 11 Jan 1999 19:33:20 IST |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hello,
We are facing a problem with setjmp()/longjmp() on MPE-ix.
The below are the details.
If anybody knows a workaround or solution to this problem.
Please let us know about it.
Thanks in advance for your help.
Regards,
Sanjeev.
>---------------------------------------------------------------------------
>Details of setjmp()/longjmp() problem with shared library on MPE.
>---------------------------------------------------------------------------
>(1). What is the problem it has been seen ?
>
>The scenario of the problem is as below :
>
>1. We do a setjmp() in application code.
>2. Then call an API which is in a shared library. This takes the control
> to shared library which is in another space.
>3. A longjmp() is called by the API.
> (NOTE: we are in a different space from the one where setjmp() was called).
>
> The longjmp() returns to a place which is illegal and the program
> aborts.
>
>
>The problem is that setjmp() does not save the space-id and the
>longjmp() does not restore it. Now, since we are in different space and
>only offset is restored, the process aborts.
>
>---------------------------------------------------------------------------
>(2). How to reproduce the problem ?
>
>Test code
>---------
>#include <pthread.h>
>#include <dce/exc_handling.h>
>
>EXCEPTION anerror;
>
>void boom_finally(){
> TRY { /* This is a macro and does a setjmp() */
>
> printf ("boom_finally: Going to RAISE.");
>
> RAISE(anerror); /* This is a API in a XL (DCEXL) and has a longjmp() */
> printf("should not come here.\n");
> }
> CATCH (anerror) { /* This a macro */
> printf("anerror caught. \n");
> printf ("boom_finally: anerror caught.");
> }
> ENDTRY /* This is a macro */
>}
>
>void main(int argc, char *argv[], char *envp[]){
> pthread_t thread1;
>
> printf ("Test unhandled-exceptions, in the main thread.");
>
> EXCEPTION_INIT (anerror);
>
> boom_finally();
>
>}
>
>Makefile
>--------
>DEBUG =
>INCENV = -I. -I/usr/include
>ANSI_FLAGS = -D_POSIX_SOURCE
>HP_FLAGS = -D_REENTRANT -DMPEXL -D_MPEXL_SOURCE -D_SOCKET_SOURCE
>
>CFLAGS = ${ANSI_FLAGS} ${DEBUG} ${HP_FLAGS} ${INCENV}
>LDFLAGS =
>LIBS = -lc_reveal
>
>PROGRAMS = cuvb_exc_ptdexts_001
>
>all : ${PROGRAMS}
>
>cuvb_exc_ptdexts_001: cuvb_exc_ptdexts_001.o cts_test1.o
> $(CC) ${LDFLAGS} cuvb_exc_ptdexts_001.o cts_test1.o ${LIBS} -o $@
> mv -f cuvb_exc_ptdexts_001 /SYS/PUB/SLSERVER
> callci linkedit \"altprog slserver.pub.sys\;xl='\
> dcexl.hpdce.sys,othdxl.threads.sys'\"
> mv -f /SYS/PUB/SLSERVER cuvb_exc_ptdexts_001
>
>---------------------------------------------------------------------------
>(3). What is the expected behaviour with setjmp and longjmp if
> an application is linked with shared library on MPE ?
>
>
>The longjmp() should ideally return back to the space from the where the
>setjmp() was called.
>
>---------------------------------------------------------------------------
>(4). What is the current behaviour with setjmp and lingjmp calls
> if an application is linked with shared library on MPE.
>
>The longjmp() restores only the offset and not the space-id and hence
>the control is transfered to the wrong place which leads to abort.
>
>---------------------------------------------------------------------------
>(5). What is the impact if the problem is not fixed ?
>
>The Exception-handling feature of DCEXL cannot be used by the user
>applications.
>
>---------------------------------------------------------------------------
|
|
|