From 39143fc6bc3eafb318fb30ebfdb36c3c4f18d077 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 1 Aug 2023 07:24:36 -0700 Subject: [PATCH] Fix 1996/jonth for macOS The problem was the function pointer w(), which points to XCreateWindow(), did not have the parameters and this caused a segfault in macOS. Because it takes a lot of parameters I split the line up to multiple lines by having a '\' at the end of lines (the entire code is in #defined macros and two #includes). --- 1996/jonth/README.md | 3 +- 1996/jonth/jonth.c | 4 +- bugs.md | 94 -------------------------------------------- thanks-for-fixes.md | 6 +++ 4 files changed, 10 insertions(+), 97 deletions(-) diff --git a/1996/jonth/README.md b/1996/jonth/README.md index 75fabacd7..fb967e3bf 100644 --- a/1996/jonth/README.md +++ b/1996/jonth/README.md @@ -16,8 +16,7 @@ make all NOTE: this entry requires `X11/Xlib.h` header file and the X11 library to compile. macOS users running Mountain Lion and later will need to download and install [XQuartz](https://www.xquartz.org) in order to compile and run this -entry. But see [bugs.md](/bugs.md) for a known problem with running this under -macOS and with a workaround of sorts plus more information on where it fails. +entry. ## To run: diff --git a/1996/jonth/jonth.c b/1996/jonth/jonth.c index 06192abd8..710d6b2b4 100644 --- a/1996/jonth/jonth.c +++ b/1996/jonth/jonth.c @@ -2,7 +2,9 @@ #define I 8;}t(p){r(p?W:o);XClearWindow(V,m);}main(i,f)char**f;{M((T(h=f), #define K Y(o,XMapRaised(V,e);)x=3;x--;)for(y=3;y--;r(G))XMapRaised(V,R[D] #define N z(x+i,(z(H-x-i,x),x)))x20&&l>x -#define XIMOfIC Z;XID(*w)()=XCreateWindow,m,e,o[2],W[2],G[2],R[2][O]);}GC*g +#define XIMOfIC Z;XID(*w)(Display*,Window,int,int,unsigned,unsigned,unsigned,\ + int,unsigned, Visual*,unsigned long,XSetWindowAttributes*)=XCreateWindow,\ + m,e,o[2],W[2],G[2],R[2][O]);}GC*g #define E (++D)));}r(XID*z){XSetWindowBackgroundPixmap(V=d[D],m=R[D][x][y],z[ #define L ;XStoreName(V,e=w(V,RootWindow(V,s),0,0,152,152,2,0,1,0,0,0),"II"+D #define B 3][3];Display*V,*d[2];char**h,k=25,b[2500],H=50,D,s,x,y,i;T(){float diff --git a/bugs.md b/bugs.md index 6b62c03fc..b07f53969 100644 --- a/bugs.md +++ b/bugs.md @@ -930,100 +930,6 @@ it was instead requiring a login / password. Do you have an updated link? We welcome your help! ## [1996/jonth](1996/jonth/jonth.c) ([README.md](1996/jonth/README.md)) -## STATUS: doesn't work with some platforms - please help us fix - -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) noted that this does -not work properly in macOS (at least Ventura). He did some debugging and has -determined where the crash occurs (depending on invocation of the program) and -came up with a workaround of sorts but if you have a fix we welcome your help. - -With this you'll need XQuartz as described in the [FAQ](faq.md) and the -[1996/jonth/README.md](1996/jonth/README.md) file. - -Notes from Cody: - -Depending on invocation it appeared to have more than one crash location. It -appears that the correct invocation might be `./jonth :0 :0` but it still -crashes. Earlier invocations it would crash at - -```c -s=XDefaultScreen(V=d[D]=XOpenDisplay(*(h+=!! *h))); -``` - -because `XOpenDisplay()` returned NULL. But using `:0 :0` _appears_ to resolve -that problem. However instead it crashes at this code: - -```c -XMapRaised(V,R[D][x][y]=w(V,e,H*x,H*y,H,H,1,0,1,0,2048,&c)); -``` - -This is formed through the macros `K` and what appears to be `S` (but maybe -others?): - -```c -#define K Y(o,XMapRaised(V,e);)x=3;x--;)for(y=3;y--;r(G))XMapRaised(V,R[D] -#define S +k),z(k-P=w(V,e,H*x,H*y,H,H,1,0,1,0,2048,&c));}XEvent J;M(){XFlush( -``` - -and the code surrounding it will look something like: - -```c -for (o[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s), - WhitePixel(V,s),DefaultDepth(V,s)),memset(b,x=0,H*H); x 40 Window ww = w(V,e,H*x,H*y,H,H,1,0,1,0,2048,&c); - 41 XMapRaised(V,R[D][x][y]=ww); - 42 } - -``` - -...so it never reaches the call that should be using its return value. -Unfortunately if XQuartz has debug symbols I don't have access to them so I'm at -a loss at this time. - -A C pre-processed version of the code is below in case this helps you find the -problem: - -```c -#include -#include -extern XIM Z;XID(*w)()=XCreateWindow,m,e,o[2],W[2],G[2],R[2][3][3];Display*V,*d[2];char**h,k=25,b[2500],H=50,D,s,x,y,i;T(){float l;XSetWindowAttributes c;s=XDefaultScreen(V=d[D]=XOpenDisplay(*(h+=!! *h)));XStoreName(V,e=w(V,RootWindow(V,s),0,0,152,152,2,0,1,0,0,0),"II"+D);for(G[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s),WhitePixel(V,s),DefaultDepth(V,s)),memset(b,x=0,H*H);xH||z(x+i,(z(H-x-i,x),x)))x20&&l>x;l-=.5)z(x+k,y=sqrt(l*l-x*x) +k),z(k-x,y)-z(y,x+k)+z(y,k-x)*z(x+k,y=H-y),z(k-x,y),z(y,k-x),z(y,k+x);for(o[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s),WhitePixel(V,s),DefaultDepth(V,s)),memset(b,x=0,H*H);x