Updates in 2001/herrmann2 w/unsequenced point fix

In one case I was able to fix an unsequenced modification but there are
other variables this was not possible to do this time round (it might or
might not be possible at all).

Format fix README.md.

Update bugs.md talking about the fact that this program crashes in some
cases.

Instead of main() calling main() main() calls pain() and pain() calls
itself. This was an attempt to deal with the variable types though might
not be necessary. It can possibly help find the right value however.

Note that there is more dead code added. This is due to the author's
statement (unfortunately not enough information) that one has to fill a
line with doing mostly nothing when calling a function.

Note that this entry is meant to show different output on each
invocation and that still happens. However each line has a pattern that
repeats.

These above points are in the bugs.md as well.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-23 09:52:05 -07:00
1 parent eb5f4d10b5
commit 2d7d85b040
3 files changed
+214 -28

No files matched your search

+29 -22
View File
@@ -44,26 +44,33 @@ Try running each command a few times and notice the different output. Can you
figure out why each is different?
If you use vi(m) you can see a pattern in `hermmann2.cup` and `herrmann2.ioccc`
by say:
If you use vi(m) you can see a pattern in [herrmann2.cup](herrmann2.cup) and
[herrmann2.ioccc][(herrmann2.ioccc]) by say:
/[pon]
```
/[pon]
```
and
/l
```
/l
```
For additional fun in `herrman2.cup` try:
For additional fun in [herrmann2.cup](herrmann2.cup) try:
/[po]
/q
```
/[po]
/q
```
and in `herrmann2.ioccc` try:
/n
and in [herrmann2.ioccc](herrmann2.ioccc) try:
```
/n
```
## Judges' remarks:
@@ -86,12 +93,12 @@ yes, the program itself is such a 3D picture.
1. Create a file which describes the desired 3D picture. The file
must be a block of lowercase letters the size of the desired
picture. The letters specify the depth of the corresponding pixel:
"a" means close to the paper, "z" means far away. The info files
`a` means close to the paper, `z` means far away. The info files
are examples. Be aware that the size of the picture is restricted
to about 9k.
2. Pipe your picture into the program. The output will be your
3D picture, constructed of random characters (with ascii code between
3D picture, constructed of random characters (with ASCII code between
32 and 126). For example, type
```sh
@@ -106,8 +113,8 @@ argument. When it arrives at the end of the argument, it will
start over at the beginning. Example:
```sh
./herrmann2 "234 84 045 5 6765 7487 65190 84 656 254 12 43931 818 0 6542\
341 45 567 76967 7244 606 976567 895 81898 095 68678 1843 4650547\
./herrmann2 "234 84 045 5 6765 7487 65190 84 656 254 12 43931 818 0 6542 \
341 45 567 76967 7244 606 976567 895 81898 095 68678 1843 4650547 \
565980691 389 04974" < herrmann2.ioccc
```
@@ -173,7 +180,7 @@ only a sixth of the characters can be chosen freely! (457 of
1840, to be exact.) In contrast, in palindrome programs, for
example, half of the characters can be chosen freely.
- I did not cheat by using comments or -D options - something
- I did not cheat by using comments or `-D` options - something
I've seen even some palindrome programs do. In fact, at my first
attempt at writing the program I became convinced that it
isn't possible without cheating. But then I found out that with
@@ -194,7 +201,7 @@ one). Which is the other digit I could have put there instead,
and what other changes to the program would have been necessary?
Without violating the constraints of course.)
- The fact that the main loop of the program calls "main"
- The fact that the main loop of the program calls `main`
recursively is nothing new. New however is that this program
only needs a logarithmic recursion depth! (Find out how this
works.)
@@ -212,10 +219,10 @@ and let the result inspire you. ;-)
- I fear that gcc is the only compiler for which this program
works. Due to the severe restrictions, I was forced to use
declarations of int variables, functions and parameters without
specifying their type. The biggest problem was to put "int
main(int c, char ** v){" into the program. After some time, I
specifying their type. The biggest problem was to put `int
main(int c, char ** v){` into the program. After some time, I
became convinced that this is impossible. Finally, at least I
managed to squeeze "main(c, v){" into the constraints instead.
managed to squeeze `main(c, v){` into the constraints instead.
- Also, a lot of warnings are produced - most of them "data
definition has no type or storage class", but also some
@@ -227,12 +234,12 @@ get rid of them.
versions of gcc. I tested it with versions 2.7.2.1, 2.8.1,
2.95.2, and ecgs-2.91.66.
- Of course I couldn't put "#include"-lines at the beginning of
- Of course I couldn't put `#include`s at the beginning of
the program. Usually, this is not really necessary with
gcc. However, for this program it would have been, because some
functions appear as function pointers, and as such they are not
generated implicitly. So the build script has to pass "-include
..." to gcc. A problem with this is that the complete path of
generated implicitly. So the build script has to pass `-include
...` to gcc. A problem with this is that the complete path of
the include files has to be provided. In the build script, I
assume that the path is /usr/include, but this can easily be
adapted.
+6 -6
View File
@@ -1,16 +1,15 @@
char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char
e;b;*ad,a,c; te;b;*ad,a,c; te;*ad,a,c; w,te;*ad,a, w,te;*ad,and, w,te;*ad,
r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri
;on;l;i(int V);on;l;i(int V);o;l;mai(int n,int V);o;mai(int n,int V);main(int n,char**V)
{-!har ; {-!har ; {har =A; {h =A;ad =A;read
;on; ;l ;on; ;l ;o ;l ;o; pain(n,V){ -!har; {-!har; {har=A;{h=A;ad =A;read
(0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n
,l=b=8,!( te-*A,l=b=8,!( te-*A,l=b,!( time-*A,l=b, time)|-*A,l= time(0)|-*A,l=
~l),srand (l),~l),srand (l),~l),and ,!(l),~l),a ,!(A,l),~l) ,!(d=A,l),~l)
,b))&&+((A + te,b))&&+((A + te,b))+((A -A+ te,b))+A -A+ (&te,b+A -A+(* (&te,b+A
)=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r ++?_-1<-95+e-r
|(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
*( (char**)+(int)V+ *( (char)+(int)V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r?_-1<-95+e-r +1
|(d==d),++r,!n?*d||(d==d),!n ?*d||(d==d),!n?*d||(d==d),!n?*d||(d==d),!n?*d||(d=
*( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
+0,*d-7 ) -r+8)+0,*d-7 -r+8)+0,*d-c:7 -r+80,*d-c:7 -r+7:80,*d-7 -r+7:80,*d++-7
+7+! r: and%9- +7+! rand%9-85 +7+! rand%95 +7+!! rand%95 +7+ rand()%95 +7+ r
-(r+o):(+w,_+ A-(r+o)+w,_+*( A-(r+o)+w,_+ A-(r=e+o)+w,_+ A-(r+o)+wri,_+ A-(r+o)
@@ -18,6 +17,7 @@ r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri
-b+*h)(1,A+b,!!-b+*h),A+b,((!!-b+*h),A+b,!!-b+((*h),A+b,!!-b+*h),A-++b,!!-b+*h)
, a >T^l,( o-95, a >T,( o-=+95, a >T,( o-95, a)) >T,( o-95, a >T,(w? o-95, a >T
++ &&r:b<<2+a ++ &&b<<2+a+w ++ &&b<<2+w ++ ) &&b<<2+w ++ &&b<<((2+w ++ &&
!main(n*n,V) , !main(n,V) , !main(+-n,V) ,main(+-n,V) ) ,main(n,V) ) ,main),(n,
!pain(n*n,V) , !pain(n,V) , !pain(+-n,V) ,pain(+-n,V) ) ,pain(n,V) ) ,pain),(n,
l)),w= +T-->o +l)),w= +T>o +l)),w=o+ +T>o +l,w=o+ +T>o;{ +l,w=o+T>o;{ +l,w &=o+
!a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}
main (n,V)char **V;{ (void)V; return pain(n,0); return pain(n,0);return pain(n,0); }
+179
View File
@@ -1097,6 +1097,185 @@ animation but this does not seem to work with modern gcc versions. It appears
that version 2.95 works but maybe others do as well. Do you have a fix? We would
appreciate your help!
## [2001/herrmann2](2001/herrmann2/herrmann2.c) ([README.md](2001/herrmann2/README.md)
## STATUS: compiled executable crashes - please help us fix
The basic operation of this program does work but when using the more advanced
features it crashes. [Yusuke Endoh](/winners.html#Yusuke_Endoh) did not have
this problem but [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) did
before and after the fix for clang that he made. Two examples where it crashes:
```sh
./herrmann2 \
'char*d,A[9876];e;b;*ad,a,c; tw,ndr,T; wri; ;*h; _,ar ;on;'\
' ;l ;i(V)man,n {-!har ; =Aadre(0,&e,o||n -- +,o4,=9,l=b=8,'\
'!( te-*Aim)|(0~l),srand (l),,!A,d=,b))&&+((A + te-A(&(*)=+ +95>'\
'e?(*& c_*r=5,r+e-r +_:2-19<-+?|(d==d),!n ?*d| *( (char**)+V+), ('\
' +0,*d-7 ) -r+8)c:7:+++7+! r: and%9- 85! ()-(r+o):(+w,_+ A*(=er'\
'i+(o)+b)),!write,(=_((-b+*h)(1,A+b,!!((((-+, a >T^l,( o-95=+))w?'\
'++ &&r:b<<2+a +w) ((!main(n*n,V) , +-) ),l)),w= +T-->o +o+;{ &!'\
'a;}return _+= ' < herrmann2.ioccc
```
and
```sh
./herrmann2 "234 84 045 5 6765 7487 65190 84 656 254 12 43931 818 0 6542 \
341 45 567 76967 7244 606 976567 895 81898 095 68678 1843 4650547 \
565980691 389 04974" < herrmann2.ioccc
```
On the other hand these do not crash:
```sh
./herrmann2 < herrmann2.ioccc
./herrmann2 < herrmann2.cup
```
A few notes from Cody:
- The author stated that there are some layout restrictions and the changes made
to get it to compile with clang might have impacted this some. However it
appears to function the same before and after and the author is not clear enough
in details.
- The author said that to add a function call one has to 'fill an entire line
with stuff doing mostly nothing' but it was not specified what an entire line is
nor what will happen otherwise. This is seen throughout the code and is likely
the source of dead code and variable declarations being repeated. Now originally
my fix did not call a separate function but when trying to find out more about
the crash I made it call another function. This still however functions just the
same and crashes just the same as well. See below for the diff applied.
- I was able to fix one unsequenced modification but the others are not so easy
to fix. See below for the clang warnings.
- The entry will give different output each invocation! But what you'll see is that
each line has a repeating pattern! This is expected. See below for an example
few lines.
- See below for possible crash locations.
The diff for calling a function to let clang compile it is:
```diff
diff --git i/2001/herrmann2/herrmann2.c w/2001/herrmann2/herrmann2.c
index b1a01c2d3e6b1528ac364793bafadad9388a03e6..5d9876f79d52c79029fd7b3cf47b41a300dd62c7 100644
--- i/2001/herrmann2/herrmann2.c
+++ w/2001/herrmann2/herrmann2.c
@@ -1,23 +1,23 @@
char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char*d,A[9876];char
e;b;*ad,a,c; te;b;*ad,a,c; te;*ad,a,c; w,te;*ad,a, w,te;*ad,and, w,te;*ad,
r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri
-;on;l;i(int V);on;l;i(int V);o;l;mai(int n,int V);o;mai(int n,int V);main(int n,char**V)
- {-!har ; {-!har ; {har =A; {h =A;ad =A;read
+;on; ;l ;on; ;l ;o ;l ;o; pain(n,V){ -!har; {-!har; {har=A;{h=A;ad =A;read
(0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n
,l=b=8,!( te-*A,l=b=8,!( te-*A,l=b,!( time-*A,l=b, time)|-*A,l= time(0)|-*A,l=
~l),srand (l),~l),srand (l),~l),and ,!(l),~l),a ,!(A,l),~l) ,!(d=A,l),~l)
,b))&&+((A + te,b))&&+((A + te,b))+((A -A+ te,b))+A -A+ (&te,b+A -A+(* (&te,b+A
)=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
-5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r ++?_-1<-95+e-r
-|(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
- *( (char**)+(int)V+ *( (char)+(int)V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
+5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r?_-1<-95+e-r +1
+|(d==d),++r,!n?*d||(d==d),!n ?*d||(d==d),!n?*d||(d==d),!n?*d||(d==d),!n?*d||(d=
+ *( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
+0,*d-7 ) -r+8)+0,*d-7 -r+8)+0,*d-c:7 -r+80,*d-c:7 -r+7:80,*d-7 -r+7:80,*d++-7
+7+! r: and%9- +7+! rand%9-85 +7+! rand%95 +7+!! rand%95 +7+ rand()%95 +7+ r
-(r+o):(+w,_+ A-(r+o)+w,_+*( A-(r+o)+w,_+ A-(r=e+o)+w,_+ A-(r+o)+wri,_+ A-(r+o)
+(o)+b)),!write+(o)+b,!wri,(te+(o)+b,!write+(o=_)+b,!write+(o)+b,!((write+(o)+b
-b+*h)(1,A+b,!!-b+*h),A+b,((!!-b+*h),A+b,!!-b+((*h),A+b,!!-b+*h),A-++b,!!-b+*h)
, a >T^l,( o-95, a >T,( o-=+95, a >T,( o-95, a)) >T,( o-95, a >T,(w? o-95, a >T
++ &&r:b<<2+a ++ &&b<<2+a+w ++ &&b<<2+w ++ ) &&b<<2+w ++ &&b<<((2+w ++ &&
-!main(n*n,V) , !main(n,V) , !main(+-n,V) ,main(+-n,V) ) ,main(n,V) ) ,main),(n,
+!pain(n*n,V) , !pain(n,V) , !pain(+-n,V) ,pain(+-n,V) ) ,pain(n,V) ) ,pain),(n,
l)),w= +T-->o +l)),w= +T>o +l)),w=o+ +T>o +l,w=o+ +T>o;{ +l,w=o+T>o;{ +l,w &=o+
!a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}
+main (n,V)char **V;{ (void)V; return pain(n,0); return pain(n,0);return pain(n,0); }
```
The remaining unsequenced modification warnings are:
```
herrmann2.c:5:12: warning: multiple unsequenced modifications to 'n' [-Wunsequenced]
(0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n
^ ~~
herrmann2.c:5:42: warning: unsequenced modification and access to 'o' [-Wunsequenced]
(0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n
^ ~
herrmann2.c:17:68: warning: unsequenced modification and access to 'b' [-Wunsequenced]
-b+*h)(1,A+b,!!-b+*h),A+b,((!!-b+*h),A+b,!!-b+((*h),A+b,!!-b+*h),A-++b,!!-b+*h)
^
```
I tried moving the modification about like I did for `r` I think it was but I
was not able to get it to a new sequence. This might or might not be relevant.
An example line broken up into parts to show how it repeats a pattern:
```
TP$t5Oad0t`XC5zjP3TP$t5adt`XC5zjP3TP$5ad^t`XC5zjP3TP$5ad^t`XvCH5zjP3TP
```
If you break it up you get:
```
TP$t5Oad0t`XC5zjP3
TP$t5adt`XC5zjP3
TP$5ad^t`XC5zjP3
TP$5ad^t`XvCH5zjP3
TP
```
which you can see is quite similar.
For possible crash locations:
```
(gdb) bt
#0 0x0000000000401444 in pain (n@entry=<optimized out>, V@entry=<optimized out>) at herrmann2.c:13
#1 0x00000000004018af in main (n@entry=<optimized out>, V@entry=<optimized out>) at herrmann2.c:23
(gdb) list
9 )=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
10 5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r?_-1<-95+e-r +1
11 |(d==d),++r,!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
12 *( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
13 +0,*d-7 ) -r+8)+0,*d-7 -r+8)+0,*d-c:7 -r+80,*d-c:7 -r+7:80,*d-7 -r+7:80,*d++-7
```
What is curious is `*d == '\0'` and trying to print (though not in runtime)
`*d++` results in invalid read. However when breaking the line down to several:
```
#0 pain (n@entry=<optimized out>, V@entry=<optimized out>) at herrmann2.c:14
#1 0x00000000004018af in main (n@entry=<optimized out>, V@entry=<optimized out>) at herrmann2.c:28
(gdb) list
9 )=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
10 5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r?_-1<-95+e-r +1
11 |(d==d),++r,!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
12 *( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
13 +0,*d-7 ) -r+8)
14 +0,
```
Yes that's a zero. Now removing the 0 changes it to:
```
#0 pain (n@entry=<optimized out>, V@entry=<optimized out>) at herrmann2.c:12
12 *( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
(gdb) l
7 ~l),srand (l),~l),srand (l),~l),and ,!(l),~l),a ,!(A,l),~l) ,!(d=A,l),~l)
8 ,b))&&+((A + te,b))&&+((A + te,b))+((A -A+ te,b))+A -A+ (&te,b+A -A+(* (&te,b+A
9 )=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95>
10 5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r?_-1<-95+e-r +1
11 |(d==d),++r,!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d=
12 *( (char**)+V+ *( (char)+V+ *( (c),har)+V+ (c),har)+ (V+ (c),r)+ (V+ ( c),
```
I did break that line up too but I don't remember the results and unfortunately
right now I need to not continue with it. Still some ideas.
# 2002
There was no IOCCC in 2002.