Around 18 o'clock on Feb 19, Juliusz Chroboczek wrote:

> Why's that?  Is setjmp/longjmp verboten in modules, or is FreeType
> doing something non-portable?

Yes, it appears that setjmp/longjmp are not permitted in any XFree86 code. 
Not by intent, but by implementation.  Here's what I found in the 
libc_wrapper code:

        int
        xf86setjmp(xf86jmp_buf xf86env)
        {
            return setjmp((void *)xf86env);
        }
        
        void
        xf86longjmp(xf86jmp_buf xf86env, int val)
        {
            longjmp((void *)xf86env, val);
        }

Given the way setjmp and longjmp work, there's no way these will ever be 
useful -- the stack frame from which setjmp operates will disappear after 
xf86setjmp returns, any call to xf86longjmp after that will jump into a 
garbage stack frame and explode.

Here's a patch which has applications call the real setjmp/longjmp 
directly (and makes xf86jmp_buf larger than jmp_buf).  Testing would be 
greatly appreciated.

-keith
Index: hw/xfree86/loader/xf86sym.c
===================================================================
RCS file: /home/x-cvs/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v
retrieving revision 1.224
diff -u -r1.224 xf86sym.c
--- hw/xfree86/loader/xf86sym.c 9 Feb 2003 00:18:18 -0000       1.224
+++ hw/xfree86/loader/xf86sym.c 19 Feb 2003 19:26:32 -0000
@@ -26,6 +26,7 @@
 #define INCLUDE_DEPRECATED 1
 
 #include <fcntl.h>
+#include <setjmp.h>
 #include "sym.h"
 #include "misc.h"
 #include "mi.h"
@@ -887,8 +888,8 @@
    SYMFUNC(xf86shmat)
    SYMFUNC(xf86shmdt)
    SYMFUNC(xf86shmctl)
-   SYMFUNC(xf86setjmp)
-   SYMFUNC(xf86longjmp)
+   SYMFUNCALIAS("xf86setjmp",setjmp)
+   SYMFUNCALIAS("xf86longjmp",longjmp)
 #ifdef XF86DRI
                                /* These may have more general uses, but
                                    for now, they are only used by the DRI.
Index: hw/xfree86/os-support/xf86_libc.h
===================================================================
RCS file: /home/x-cvs/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v
retrieving revision 3.54
diff -u -r3.54 xf86_libc.h
--- hw/xfree86/os-support/xf86_libc.h   19 Sep 2002 13:22:02 -0000      3.54
+++ hw/xfree86/os-support/xf86_libc.h   19 Feb 2003 19:25:51 -0000
@@ -71,7 +71,7 @@
 typedef int xf86key_t;
 
 /* setjmp/longjmp */
-typedef int xf86jmp_buf[20];
+typedef int xf86jmp_buf[100];
 
 /* for setvbuf */
 #define XF86_IONBF    1
Index: hw/xfree86/os-support/shared/libc_wrapper.c
===================================================================
RCS file: /home/x-cvs/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v
retrieving revision 1.86
diff -u -r1.86 libc_wrapper.c
--- hw/xfree86/os-support/shared/libc_wrapper.c 31 May 2002 18:46:02 -0000      1.86
+++ hw/xfree86/os-support/shared/libc_wrapper.c 19 Feb 2003 19:25:14 -0000
@@ -1944,16 +1944,3 @@
     return -1;
 }
 #endif /* HAVE_SYSV_IPC */
-
-int
-xf86setjmp(xf86jmp_buf xf86env)
-{
-    return setjmp((void *)xf86env);
-}
-
-void
-xf86longjmp(xf86jmp_buf xf86env, int val)
-{
-    longjmp((void *)xf86env, val);
-}
-

Reply via email to