个人工具

UbuntuHelp:UbuntuDateBug

来自Ubuntu中文

跳转至: 导航, 搜索

This bug has been fixed for Gutsy Gibbon and later. No further action is required if you are running Gutsy or newer. There is a rather annoying bug in Ubuntu which causes it to hang if the date is set badly (before 1970 I think). It is simple to fix, but it's rarely diagnosed properly. It has been reported here: https://launchpad.net/distros/ubuntu/+source/gnome-session/+bug/23426 . It crops up occasionaly in the forums so I have put the info here to point people to.

Symptoms

The system boots fine, and gets to the gdm login screen. The user types name and password and presses enter. The screen goes and the user is left on a brown screen. That's it, just a brown screen of death. If the user is savvy they will try ctrl-alt-f1 and get a text terminal. They might try restarting gdm, reinstalling gnome, creating a new user, deleting all their gnome preference files, reinstalling the whole sytem. They probably won't check the computer clock.

How to fix

Simple, set the date right. Boot to the point of the brown screen, then press crtl+alt+f1 (ctrl-option-F1 on a Mac) to get a terminal, and log in. Type:

date

if you get something like

Fri Jan 11 19:11:32 GMT 1970

then run the command

sudo date -s "Fri Nov 11 19:11:32 GMT 2005"

(you will need to put in your password) now do the command

sudo /etc/init.d/gdm restart

and hopefully you can log in.

Why this happens

I believe the bug is related to the way the date is stored and the way c deals with numbers. In unix (and macs) the date is store as the number of seconds since the epoch (1 jan 1970). Negative values represent dates back to 1904. Now of course it is well after 1970, so why bother with being able to set your clock to before 1970. (if you want to store birthdays in a program you might need to, but not for the current date). In c you can store numbers as signed or unsigned. If they are signed they can be negative or positive. Most computers store their time in a signed number, gnome seems to use a signed number, but the kernel seems to use unsigned. So if your computer clock can be set before 1970, most stuff will work fine, however gnome will not boot. Apple Mac computers can be set to dates back to 1904. If the clock in a mac is reset it will go to 1904. The clock in a mac is kept going by the PRAM battery, which runs out after about 5 years. After this time if the mains goes off then the clock will reset, and gnome wont boot. (It can also be reset after a bad crash.) The long term fix on a mac is to replace your PRAM battery.