It could be a logic board failing, or a HD, or some malicious software. Try a safe boot and see if safari works, and any of your other applications work (apple applications only) as the safe boot will disable 3rd party applications. Safe boot: power up holding the shift key, continue to hold the shift key till you see the progress bar, then you can release it and let it finish booting.(This will take a little longer, so be patient) Launch safari and see if it works normally, if it does, try shutting down and boot normally launch it again and see if it quits. If it fails you probably take it to the Apple store for diagnosis. They do this for free, and will tell you how much it will cost to repair it.
Disconnect all peripherals from your computer.
Boot from your install disc & run Repair Disk from the utility menu. To use the Install Mac OS X disc, insert the disc, and restart your computer while holding down the C key as it starts up.
Select your language.
Once on the desktop, select Utility in the menu bar.
Select Disk Utility.
Select the disk or volume in the list of disks and volumes, and then click First Aid.
Click Repair Disk.
Restart your computer when done.
Repair permissions after you reach the desktop-http://support.apple.com/kb/HT2963 and restart your computer.