Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how badly can c crash?

Tags:

c

crash

I have often heard that C can crash spectacularly. Recently I got my first taste of this when a function I expected to return a string instead returned little happy faces. Since then I have been being more careful with initializing pointers and mallocing memory for arrays. Still, though, I have trouble believing that a program could crash THAT badly...

I guess it would depend on the scope of the program though? I mean, if a bug in a program that dealt with your fan copied happy faces into some important space in memory...?

My question is, how much myth is there in the world of spectacular C crashes? Can I get some concrete examples of dangerous things that one ought to avoid?

z.

like image 640
Ziggy Avatar asked Mar 12 '09 21:03

Ziggy


2 Answers

alt text

  • http://xkcd.com/371/
  • http://blog.raamdev.com/category/technology/programming/cc
  • http://en.wikipedia.org/wiki/Segmentation_fault
like image 117
Tom Ritter Avatar answered Oct 19 '22 12:10

Tom Ritter


I think it was probably worse way back in the pre-virtual memory days when you could trash other processes memory, but nowadays the worst that can happen is really just crashing your own program. Usually via segmentation faults from bad pointers.

That excludes of course blowing things up by misusing system resources - you can do that in any language.

like image 32
Eric Petroelje Avatar answered Oct 19 '22 11:10

Eric Petroelje