Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Shortest way to segfault on C

Name: Anonymous 2009-10-17 15:47

main(){main();}

Name: Anonymous 2009-10-17 15:51


#define main() m

m { m ;}

Name: Anonymous 2009-10-17 15:54

>>2
It's funny because you're actually writing more.

Name: Anonymous 2009-10-17 16:30

main=58;

Name: Anonymous 2009-10-17 16:34

main=0;

Name: Anonymous 2009-10-17 16:35

$ gcc -x c -Dm='main(){strdup(1);}' -
m

Name: Anonymous 2009-10-17 16:35

main;

Name: Anonymous 2009-10-17 16:41

>>7
It's hard to believe that actually compiles

Name: Anonymous 2009-10-17 16:42

>>8
warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘main’
warning: ‘main’ is usually a function

Name: Anonymous 2009-10-17 16:43

>>6
echo -n | cc -x c -nostdlib -

Name: Anonymous 2009-10-17 16:44

>>9
Yes, but who ever listened to warnings

Name: Anonymous 2009-10-17 16:46

>>11
No, they explain what happens:

main; is equivalent to int main;

Name: Anonymous 2009-10-17 19:11

>>4,5
GENIUS!

Name: Anonymous 2009-10-18 7:42

>>12
So what, it's a prototype declaration?
Also, wtf is main=5; doing? Declaring main as an int, assiging 5 and then making libc attempt to call a variable?

Name: Anonymous 2009-10-18 9:45

>>14
So what, it's a prototype declaration?
Variable declaration (without initializing it)... hmm, what are global variables initialized to?  They can't very well take on a random value, because they aren't allocated on the stack, right? I know static globals are zeroed.
Also, wtf is main=5; doing? Declaring main as an int, assiging 5 and then making libc attempt to call a variable?
Correct. Calling a variable is equivalent to jumping to its position, then executing the bytes that represent it (and subsequent data).

Name: Anonymous 2009-10-18 10:14

[metatroll:Unix/Cee]% ed maineq5.c
maineq5.c: No such file or directory
a
int main = 5;
.
w
14
q
[metatroll:Unix/Cee]% gcc -o i_am_bleeding maineq5.c
[metatroll:Unix/Cee]% ./i_am_bleeding
zsh: bus error  ./i_am_bleeding
[metatroll:Unix/Cee]%

It didn't even warn me or anything. I'm impressed!

Name: Anonymous 2009-10-18 10:30


CL-SHELL> emacs -nw maineq5.lisp
(setq main 5) C-a C-c C-c C-c C-x
CL-SHELL>

It didn't even warn me or anything. I'm impressed!

Name: Anonymous 2009-10-18 10:32


vim maineq5.perl
i#!/usr/bin/perl
return (0);,.;wq

It didn't even warn me or anything. I'm impressed!

Name: >>16-chan 2009-10-18 10:49

>>17-18
( ≖‿≖)

Name: Anonymous 2009-10-18 10:56

>>17
What is this `CL-SHELL'?

Name: Anonymous 2009-10-18 11:04

>>20
Google, 3rd hit.

Name: Anonymous 2009-10-18 12:18

>>17
Did you just invoke emacs to edit a single file? Emacs is a DAEMON!

Name: Anonymous 2009-10-18 12:28

>>22
Is this just your way of saying ``I've read SICP'' ?

Name: Anonymous 2009-10-18 12:42

>>23
Replies on /prog/ keep getting lazier and lazier :(

Name: Anonymous 2009-10-18 13:32

>>24
excuse me?

Name: Anonymous 2009-10-18 13:40

>>25
LIKE DEAD DOGS

Name: Anonymous 2009-10-18 14:58

main=195;
And I failed ;_;

Name: Anonymous 2009-10-18 18:13

>>15
Thanks for the explanation. Tbh, I was expecting flame/trolls, but yeah... thanks

Name: Anonymous 2010-11-13 13:45

Name: Anonymous 2013-02-07 22:59

       _..._                                                 _..._                                                                             
    .-'_..._''.                                           .-'_..._''.                                                                          
  .' .'      '.\    .                  __.....__        .' .'      '.\      .                     ,.--.         __.....__       __  __   ___   
 / .'             .'|              .-''         '.     / .'               .'|                    //    \    .-''         '.    |  |/  `.'   `. 
. '              <  |             /     .-''"'-.  `.  . '               .'  |                    \\    |   /     .-''"'-.  `.  |   .-.  .-.   '
| |               | |            /     /________\   \ | |              <    |                     `'-)/   /     /________\   \ |  |  |  |  |  |
| |               | | .'''-.     |                  | | |               |   | ____                  /'    |                  | |  |  |  |  |  |
. '               | |/.'''. \    \    .-------------' . '               |   | \ .'                        \    .-------------' |  |  |  |  |  |
 \ '.          .  |  /    | |     \    '-.____...---.  \ '.          .  |   |/  .                          \    '-.____...---. |  |  |  |  |  |
  '. `._____.-'/  | |     | |      `.             .'    '. `._____.-'/  |    /\  \                          `.             .'  |__|  |__|  |__|
    `-.______ /   | |     | |        `''-...... -'        `-.______ /   |   |  \  \                           `''-...... -'                    
             `    | '.    | '.                                     `    '    \  \  \                                                           
                  '---'   '---'                                        '------'  '---'                                                         

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List