Though the OS X operating system is very robust at handling software-related crashes and hangs, there are times when a problem may be beyond the scope of the operating system's abilities to manage and the system can either crash or freeze. When this happens, the system may show some clue in the system console, but likely it may only be a brief but repeating message that mentions something like the following:
Dec 20 13:33:23 localhost kernel: AppleSMU -- shutdown cause = 3
What is happening here is the system's power manager (called the Power Management Unit or "PMU" on PowerPC machines, and the System Management Controller or "SMC" on Intel machines) is receiving a signal to perform an emergency shutdown of the system, and cuts power to the system in ways that serve to prevent surges and other harmful electrical events.
The power manager can receive the signal for a variety of reasons including user-initiated events, loss of power to the system, a fault in a component, fault in a sensor, or overheating. The system will receive the signal, the power manager will store the event as a number code, and then will shut the system down.
When the system starts back up, the kernel will poll the power manager for any events to output to the system log, and if there was an unexpected shutdown it will output the event to the log. Unfortunately there is little information on the exact meaning of the number codes used for these events, but when they happen they are because of a hardware-level failure that is resulting in the system crashing.
If this happens, the first thing to do is unplug all peripheral devices and run the hardware diagnostics tools that are included on the gray restore DVDs that came with your system. Insert the boot DVD and start up the system while holding the "D" key, and the system should boot into the diagnostics tools. Run all of the tools to see if there are any detectable problems with the system components. You might also use tools like TechTool Pro (included with AppleCare) to perform more-extensive tests on some system components.
If the diagnostics check out, next try resetting some hardware settings including the PRAM and the System Management Controller (or Power Management Controller on PowerPC systems). To reset the PRAM, reboot the system with the Option-Command-P-R keys held down. Let the system cycle through a couple of resets with these keys held, and then release them and allow the system to boot normally.
Unlike resetting the PRAM, the method for resetting the power managers will be different for different Mac models. Some only require shutting off and unplugging the system, whereas others require holding specific key combinations, and others require depressing reset buttons on the motherboard. To see the specific steps for resetting the power manager on your Mac, check the following knowledgebase articles or search the Internet for your Mac model (e.g., "iMac") followed by either "PMU" or "SMC" depending on whether or not it is a PowerPC machine or an Intel machine.
Once the power manager is reset, start up the system to see if the problem persists. If so then you likely are experiencing a problem with the power supply on your computer. Over time power supplies can begin to fail for a number of reasons, and may fluctuate to outputting lower wattage than is necessary to keep the system running.
Unfortunately replacing the power supply will require you to have the system serviced by an Apple technician, but may be a simple solution to the random crashes and freezes caused by this issue.