Live data from Hacker News

The Shortest Crashing C Program

llbit.se

21–30 of 94 posts

Re: The Shortest Crashing C Program

#21
post #14

The first IOCCC winner declared main as a short[] of VAX machine code: http://www.ioccc.org/1984/mullender.c You could probably do the same thing in x86 and it'd work on a modern compiler.

It won't work on modern Linux with modern CPUs because the array will not be in an executable mapping.

Re: The Shortest Crashing C Program

#23

Earlier quoted context omitted.

It can't be a valid C89 program. On many Harvard architecture based microprocessors data pointers and code pointers have differing size.

Different size maybe, but different busses^H^H^H^H^H^Haddress spaces definitely, and using an address on the wrong bus is a sure way to cause problems.

Of course that is the definition of a Harvard architecture. It doesn't says that it won't link, just that it won't work. If compiling to an architecture with smaller sized code pointers than data pointers then the linker will most likely refuse to link it at all - otherwise it will have to truncate the adresses.

Re: The Shortest Crashing C Program

#27
post #16

Earlier quoted context omitted.

That's a shame. At least in one point in history, that was the shortest-known quine: http://www.ioccc.org/years.html#1994_smr

It still is, provided you follow the build procedure prescribed by the author of that quine (check the Makefile from the contest): $ rm -rf a $ cp a.c a $ chmod +x a $ ./a $

Even with the regular procedure, it's a quine if you ignore stderr and only look at stdout, which should definitely count.

Re: The Shortest Crashing C Program

#28
post #16

Earlier quoted context omitted.

That's a shame. At least in one point in history, that was the shortest-known quine: http://www.ioccc.org/years.html#1994_smr

It still is, provided you follow the build procedure prescribed by the author of that quine (check the Makefile from the contest): $ rm -rf a $ cp a.c a $ chmod +x a $ ./a $

I find it interesting that displays the error from exec, but not bash:

    zsh: exec format error: ./a

Re: The Shortest Crashing C Program

#29
post #7

It depends on the definition. You can do better than this if you define a valid C program as anything that passes though the C compiler and generates an executable. Behold the zero length program: $ touch a.c $ gcc -c a.c $ ld a.o ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078 $ ./a.out Segmentation fault

[deleted]

Re: The Shortest Crashing C Program

#30
post #7

It depends on the definition. You can do better than this if you define a valid C program as anything that passes though the C compiler and generates an executable. Behold the zero length program: $ touch a.c $ gcc -c a.c $ ld a.o ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078 $ ./a.out Segmentation fault

Does not compute. At least on OS X:

   $ ld a.o
   ld: warning: -macosx_version_min not specified, assuming 10.7
   Undefined symbols for architecture x86_64:
    "start", referenced from:
       implicit entry/start for main executable
   ld: symbol(s) not found for inferred architecture x86_64
Post reply on HN