pouët.net

Go to bottom

Fun Compo: Smallest Program that..

category: general [glöplog]
...but i'm pretty certain such trickeries shouldn't count :)

gargaj: what do you mean, "valid code there"? it's no jump or anything, if it doesn't crash from loading an invalid selector, it just runs on (...and probably crashes later :)
added on the 2007-11-17 18:50:00 by ryg ryg
fr33ke, changing segment registers isn't a privileged operation.
added on the 2007-11-17 18:50:39 by ryg ryg
How about:

int main(){return main();}

Surely that's never optimized to a loop?

I think 1/0 anywhere would upset the compiler if it attempts to optimize.
added on the 2007-11-17 18:50:51 by doomdoom doomdoom
haha.. this is becoming rocket science here.. :)
cool results..
i would vote for a tie (ryg and fr33ke)?! cause both solutions are cool and "somehow" do what they should on most systems..
added on the 2007-11-17 18:52:11 by toxie toxie
Yeah, VC++ refuses to compile undefined constants. ;)
added on the 2007-11-17 18:54:27 by doomdoom doomdoom
And isn't the thing about pop es that it corrupts the stack, not that it changes es?
added on the 2007-11-17 18:55:49 by doomdoom doomdoom
Code:int main(){int x=x;}


crashes with vc++ in debug mode :P
added on the 2007-11-17 18:55:58 by src src
doom, just popping something doesn't corrupt the stack, and since main() gets called from inside the c library, there's a valid return address on the stack, so you don't have a stack underflow either. you'd need to return afterwards to have problems with stack corruption, but fr33kes code just runs on... but then, the next two bytes are "00 00", which is the "add [eax],al" that most certainly also causes the crash in my variant where the variable is uninitialized .)
added on the 2007-11-17 18:59:06 by ryg ryg
Quote:
it's no jump or anything

eh, my bad, for some reason i thought es was the code segment (doh!)
added on the 2007-11-17 19:02:12 by Gargaj Gargaj
at least be fruitful and code the biggest loaderbar ever!
ryg: It does if you haven't popped anything. Ie. the function won't be able to load the return address off the stack if you've messed with the stack pointer. But then, that's based on the weird idea i for some reason had that "7" is a function that ends in a return instruction. So, good point there. ;)

Anyway, x86 must have an illegal opcode you could put there instead of "pop es", to trigger a guaranteed exception straight away. Or maybe just whatever "divide register by the immediate value 0" assembles to. It should fit in an int if I remember my x86.
added on the 2007-11-17 21:36:33 by doomdoom doomdoom
st 7

assembles fine in AsmPro and does the job.

When run in WinUAE it actually crashes the emulator, not just the emulated Amiga. ;)
added on the 2007-11-17 21:40:20 by Blueberry Blueberry
blueberry:

nice but it doesn't crash my version of winuae. :D sf 6 however does. :D
added on the 2007-11-17 21:44:39 by StingRay StingRay
So the C version to crash an Amiga:

main = 1358430215;

My WinUAE survives both st 7 and sf 6 though. Anyway, I have to say, crashing the program, the operating system and the (virtual) machine in one instruction is pretty impressive.
added on the 2007-11-17 21:56:40 by doomdoom doomdoom
hehe. nicely optimized =) .w ftw :D
added on the 2007-11-17 22:09:18 by StingRay StingRay
Quote:
It does if you haven't popped anything.


That makes a lot more sense if you substitute popped for pushed. See apparently I'm high. :)
added on the 2007-11-18 01:47:32 by doomdoom doomdoom
my two favorite ways to crash a computer in x86 assembly are:

CLI
HLT
= 2 bytes

POP CS
= 1 byte
added on the 2007-11-18 11:40:16 by p01 p01
$4AFC ??
added on the 2007-11-18 11:48:41 by gwEm gwEm
poi: pop cs is 6 bytes since this is a source code compo. however, we can rephrase it as
Code:db 15

since that is 5 bytes ;) same effect for db 99, but other db NNs survive without a crash.
added on the 2007-11-18 12:34:30 by Ger Ger
main;

Compiles with gcc and crashes on quite many systems.
it doesnt crash, but.... die; (php)
added on the 2007-11-18 21:01:54 by rmeht rmeht
rmeht - if you want to play that game...
<?$
parse error
<?f();?>
fatal error
<?for(;;)$t[]="";?>
out of memory error

I've yet to find something that'll actually crash the php interpreter though, at least in 5.2.5 :D
added on the 2007-11-18 21:49:20 by micksam7 micksam7
Ger: Oh, I didn't notice it was about source code size.
added on the 2007-11-19 13:01:20 by p01 p01
Blueberry's bit compiles fine in asmone 1.48 on e-uae; it doesn't crash e-uae however.
Of course it compiles fine. It's a valid instruction. ;) But yeah, I think he and Stingray need to upgrade their WinUAEs to an earlier version.
added on the 2007-11-19 22:27:06 by doomdoom doomdoom

login

Go to top