[TAG] Nasty Gentoo init bug
mso@oz.net
mso
Tue Apr 5 02:07:26 MSD 2005
There's a nasty race condition in Gentoo's init.d handling that's biting
users right now. At boot time or when you run an init.d script, you might
get:
- A dump of RC_DEPEND_TREE noting syntax errors.
- An error like "/sbin/rc: /var/lib/init.d/deptree: line 168: unexpected
end of file.
- A segfault.
Depending which part of the dependency tree is fubar'd, you may find one
service doesn't start, you can't get to the network, kdm won't start, you
get scary "Segmentation fault" messages, the system won't shut down
cleanly, "emerge" stops working, etc.
If this happens, take a deep breath and start any essential services
manually:
``
# ifconfig eth0 <MY_IP> up # For static IP users.
# dhcpcd -d -D -H # For DHCP users.
# ifconfig lo 127.0.0.1 up # Required for KDE and other stuff.
# /usr/kde/3.2/bin/kdm # Start KDM.
''
Some things like Apache have such an elaborate init.d setup that it's not
worth reproducing manually, so just leave those for now.
Download this patch (from bug #48303 at bugs.gentoo.org):
===== SNIP HERE gendepends.awk.diff =====
--- gendepends.awk.orig 2005-02-23 18:00:58.385854952 +0100
+++ gendepends.awk 2005-02-23 17:48:27.000000000 +0100
@@ -335,9 +335,19 @@
DEPTYPES = ENVIRON["DEPTYPES"]
ORDTYPES = ENVIRON["ORDTYPES"]
- CACHEDTREE = SVCDIR "/deptree"
-
- assert(dosystem("rm -f " CACHEDTREE ), "system(rm -f " CACHEDTREE
")")
+ #CACHEDTREE = SVCDIR "/deptree"
+ ORIGCACHEDTREE = SVCDIR "/deptree"
+
+ # Since this could be called more than once simultaneously, use a
+ # temporary cache and rename when finished. See bug 48303
+ ("/bin/mktemp "SVCDIR"/treecache.XXXXXXX") | getline CACHEDTREE
+ if (CACHEDTREE == "") {
+ eerror("Failed to create temporary cache!")
+ exit 1
+ }
+
+ #assert(dosystem("rm -f " CACHEDTREE ), "system(rm -f " CACHEDTREE
")")
+ assert(dosystem("rm -f " ORIGCACHEDTREE ), "system(rm -f "
ORIGCACHEDTRE
E ")")
{
@@ -486,6 +496,8 @@
print "LOGGER_SERVICE=" >> (CACHEDTREE)
close(CACHEDTREE)
+
+ system("mv "CACHEDTREE" "ORIGCACHEDTREE)
}
===== SNIP HERE =====
and do:
``
# cd /lib/rcscripts/awk
# cp gendepends.awk gendepends.awk.bak
# patch gendepends.awk gendepends.awk.diff
''
Have a boot/rescue disk handy just in case.
Background: Gentoo uses a custom init.d handler that creates a dependency
graph (tree) based on information in the init.d scripts themselves, and
uses that to determine which services to start before others. Most other
distributions use System V Init, which sorts a directory of numbered
symlinks and starts the services in that order. Unfortunately the program
is not concurrency-safe, so two two processes might update the graph file
at the same time and partially overwrite each other. The fix uses
temporary files and atomic operations to prevent the race condition.
Relevant threads:
http://bugs.gentoo.org/show_bug.cgi?id=48303
http://forums.gentoo.org/viewtopic-t-165438-highlight-.html
http://forums.gentoo.org/viewtopic-t-315906-highlight-.html
Hopefully this will be fixed soon in the distribution.
More information about the TAG
mailing list