From c88811c1bf774fe8a7af99bd021567c7fe264c37 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 18 Apr 2023 05:08:22 -0700 Subject: [PATCH] Update and fixes in 1996/jonth I note that this entry does not work in macOS even with XQuartz. The invocation recommended caused a crash but I came up with an invocation that made it go further along - but still also crash. I wrote in bugs.md details about it as well as giving a workaround in macOS (involves another system with X11 forwarding - no not xhost). There is some C pre-processed code in bugs.md in case this helps. The URL of the author is dead and the Internet Wayback Machine was of no help so it was removed from winners.csv and winners.html as well. It was added as a missing link in bugs.md. It was not in the earlier entry from 1993 (they won twice) so I did not put it there. Format fixes in README.md. --- 1996/jonth/README.md | 50 +++++---- bugs.md | 259 +++++++++++++++++++++++++++++++++++++++++++ tmp/winners.csv | 2 +- winners.html | 2 +- 4 files changed, 292 insertions(+), 21 deletions(-) diff --git a/1996/jonth/README.md b/1996/jonth/README.md index 744e3908c..75fabacd7 100644 --- a/1996/jonth/README.md +++ b/1996/jonth/README.md @@ -1,45 +1,57 @@ # Best X11 Entry - Jon Thingvold - University of Oslo - Gaustadveien 10B - N 0372 Oslo - Norway - - http://www.uio.no/~jonth/ +Jon Thingvold +University of Oslo +Gaustadveien 10B +N 0372 Oslo +Norway +http://www.uio.no/~jonth/ ## To build: - make all +```sh +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. + ## To run: - ./jonth +```sh +./jonth :0 :0 +``` ## Try: - ./jonth host1:0 host2:0 +```sh +./jonth host1:0 host2:0 +``` ## Judges' remarks: -For extra credit, figure out how you can cheat by taking over -a square already occupied by an opponent. +For extra credit, figure out how you can cheat by taking over a square already +occupied by an opponent. ## Author's remarks: -This is multi-user tic-tac-toe for X Windows. You may give one or two X -displays as arguments to this game. +This is multi-user tic-tac-toe for X Windows. You may give one or two X displays +as arguments to this game. ### Known bugs: -Sometimes on Solaris X gets confused and this program core dumps, -solution: give two display arguments (prog host:0 host:0) +Sometimes on Solaris X gets confused and this program core dumps. The solution: +give two display arguments (`./jonth host:0 host:0`). -If one (or both) windows look like a copy of the window(s) below, -try xrefresh command. +If one (or both) windows look like a copy of the window(s) below, try +`xrefresh(1)` command. -Have a nice(1) day. +Have a `nice(1)` day. ## Copyright and CC BY-SA 4.0 License: diff --git a/bugs.md b/bugs.md index 8440b330e..d0c414984 100644 --- a/bugs.md +++ b/bugs.md @@ -800,6 +800,265 @@ We would appreciate anyone who has it or even just knows the name! Thank you. # 1996 +## [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 +#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 anonymous.cpp` and look at that file to see +the functions. It might or might not be helpful to use cpp on the beautified +source. +- After beautifying it try changing references of the macros (where not too +complicated) to their definitions. For instance in vim you might do: +`:%s/\/int */g` and then delete the line that was changed to `#define int * +int*` (or else do a range substitute so it's not changed). You might not need +this if you use the cpp. This might be useful anyway to more easily test things. +- If your system has a `setarch` tool that might or might not be of help (I'm +not too familiar with its internals). +- The code appears to do everything from one call to `exit(3)` but it makes use +of the ternary operator and possibly the comma operator. +- Check the Makefile for the defines but also observe that those are in the +source file. It appears that the entry might try compiling as well but that's +from a quick glance. +- The original main() started like: `main (char *ck, char **k)` but we made it +compilable for clang by changing it to be: `main (int cka, char **k) { char *ck += (char *)cka;` which might or might not be good. +- The author warns that only simple source (once compiled) would work so make +use of the provided source file +[2001/anonymous/anonymous.ten.c](2001/anonymous/anonymous.ten.c). To compile try +`make anonymous.ten` from the entry directory which you can then run the entry +on. Note that it needs to be compiled as a x86 program. +- The program will to an extent destroy files it is used on. See the author's +warning in their comments on that. + + +## [2001/bellard](2001/bellard/bellard.c) ([README.md](2001/bellard/README.md)) +## STATUS: probable bug (possibly depending on system) - please help test and if necessary fix + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed an initial +segfault and he also fixed the [supplementary +program bellard.otccex.c](2001/bellard/bellard.otccex.c) to test the entry on to not segfault and +seemingly work but he has no 32-bit system to test any further fixes; we +would greatly appreciate anyone's help! It appears that this entry will require +major debugging and to make it work one might need to have a deep understanding +of the ELF format. + +The author said that they compiled it with [gcc version +2.95.2](https://ftp.gnu.org/gnu/gcc/gcc-2.95.2/gcc-everything-2.95.2.tar.gz). We don't know if +a certain gcc version is necessary but it might be helpful to download and +compile that version to test it. + +# 2002 + +There was no IOCCC in 2002. + +# 2003 + +There was no IOCCC in 2003. + +# 2004 + + +## [2004/burley](2004/burley/burley.c) ([README.md](2004/burley/README.md)) +## STATUS: known bug - please help us fix + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile +with clang. He notes however that both prior to the fix (with gcc) and after the +fix (gcc, clang) it does not work: it allows input of the bet but after it +prints the hand it does not do anything with your next move. Cody provided the +following notes and tips (including possible reasons it doesn't work): + +0. Originally the `jmp_buf` was just an `int p[4][1000]`. +1. The `setjmp.h` header file was not included so the calls to `longjmp()` had +not only the wrong number of arguments but also implicitly returned int when it +actually returns void. This means that the comma operator had to be used to get +the binary expressions to work. It might be this is part of the problem. It's +possible that actually changing this introduced it to not work as some old +entries actually use invalid prototypes and work but changing them to use the +proper prototype breaks them. +2. Another possible problem is the abuse of `setjmp()` and `longjmp()` which is +known to be a problem, at least as he interprets it in his tired head (and less +experience with `longjmp`). In particular: +> The longjmp() routines may not be called after the routine which called the +> setjmp() routines returns. +See also the NOTES section of the linux man pages for `setjmp(3)` and +`longjmp(3)`. +3. The main() originally returned a call to main() which appeared to be an +infinite recursion at least as it was; now it returns a call to poke() (since +it's a poker game) which has the same number and type of args (1, `char *`) that +main() originally had. This appears to not be an infinite recursion but I might +be reading it wrong. Changing it to not return itself and the same problem +occurs so perhaps this is not the problem. It's possible that the initial call +to the `poke()` function is incorrect. +4. It might be that the requirement of the comma operator in modern compilers is +a problem. Perhaps some instances of `,1` should be `,0`? That seems plausible +as they are often used with the `&&` operator. +5. As well main() had only one arg, a `char *`, and there was a (seemingly) +needless cast to `char *` from gets(). This cast remains in the code however. +6. The code no longer uses `gets()` but `fgets()`; this is not the problem +however. +7. Sometimes the lack of a _proper_ prototype lets code work if the function is +used incorrectly so one should be careful with adding the proper prototypes. +With this entry it didn't _appear_ to be relevant but maybe it is after another +change? + + +## [2004/gavin](2004/gavin/gavin.c) ([README.md](2004/gavin//README.md)) +## STATUS: compiled executable crashes - please help us fix +## STATUS: doesn't work with some # 1997 There was no IOCCC in 1997. diff --git a/tmp/winners.csv b/tmp/winners.csv index 1f280a284..2ee28b281 100644 --- a/tmp/winners.csv +++ b/tmp/winners.csv @@ -102,7 +102,7 @@ Jim Hague,Jim_Hague,http://www.oxinet.co.uk/jim,null,bears@cix.compulink.co.uk,n John Dalbec,John_Dalbec,http://cc.ysu.edu/~jpdalbec/,null,jdalbec@cboss.com,null,null); John Tromp,John_Tromp,http://tromp.github.io/,null,john.tromp@gmail.com,null,null); John Williams,John_Williams,null,null,williams@morinda.com,null,null); -Jon Thingvold,Jon_Thingvold,http://www.uio.no/~jonth/,null,jon.thingvold@usit.uio.no,null,null); +Jon Thingvold,Jon_Thingvold,null,null,jon.thingvold@usit.uio.no,null,null); Jonathan Hoyle,Jonathan_Hoyle,http://www.jonhoyle.com,null,jonhoyle@mac.com,null,null); Joshua Karns,Joshua_Karns,null,null,jkarns275@gmail.com,null,@jkarnss); Jyrki Holopainen,Jyrki_Holopainen,http://personal.eunet.fi/pp/halo/,null,jyrki.holopainen@paetronics.fi,null,null); diff --git a/winners.html b/winners.html index 275d3ccfc..0cb3a5ffb 100644 --- a/winners.html +++ b/winners.html @@ -1154,7 +1154,7 @@ Contest