Ross Burton: Google Juice!
Poor Guido Boehm is suffering a lack of
Google Juice, as searching for him results in the Devil's Pie home page.
Hopefully this will help Guido out!
dato(at)the-barrel.org as my main address, instead of asp16(at)alu.ua.es. (But this second one, provided by my Uni, will continue to work for some more years, and not unlikely forever.)
I was not that dissatisfied with the MX host for alu.ua.es, but it has been getting on my nerves on occasion during the last five years, so I decided it was better for my health to make the change. Kudos to Alberto Gonzalez Iniesta (agi@d.o) for being my postmaster from now on, since I really didn’t feel like running my own mailserver.
The story behind the-barrel.org is certainly not unrelated to this Google search.
Actually, it is a Sun engineer joke. The 10 Mbps predecessor was a chip called the “Big MAC Ethernet” in this case, it was a mere pun, since MAC stands for Media Access Control, i.e. the Ethernet data-link layer. When they designed the 10/100 Mbps chip later on, they decided to turn the pun into a full-out joke, and they called it the “Happy Meal Ethernet.”
528 static void happy_meal_tcvr_write(struct happy_meal *hp,
529 void __iomem *tregs, int reg,
530 unsigned short value)
531
532 int tries = TCVR_WRITE_TRIES;
533
534 ASD((“happy_meal_tcvr_write: reg=0x%02x value=%04x\n”, reg, value));
535
536 /* Welcome to Sun Microsystems, can I take your order please? */
537 if (!(hp->happy_flags & HFLAG_FENABLE))
538 happy_meal_bb_write(hp, tregs, reg, value);
539 return;
540
541
542 /* Would you like fries with that? */
543 hme_write32(hp, tregs + TCVR_FRAME,
544 (FRAME_WRITE (hp->paddr << 23)
545 ((reg & 0xff) << 18) (value & 0xffff)));
546 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
547 udelay(20);
548
549 /* Anything else? */
550 if (!tries)
551 printk(KERN_ERR “happy meal: Aieee, transceiver MIF write bolixed\n”);
552
553 /* Fifty-two cents is your change, have a nice day. */
554
[Taken from drivers/net/sunhme.c in linux-2.6]
mh@namakemono:/tmp$ wget "http://download.mozilla.org/?product=firefox-1.5b2&os=linux&lang=en-US"
(...)
mh@namakemono:/tmp$ tar -zxf firefox-1.5b2.tar.gz
mh@namakemono:/tmp$ cd firefox/
mh@namakemono:/tmp/firefox$ ./firefox
./run-mozilla.sh: line 131: 7540 Segmentation fault "$prog" $ 1+"$@"
mh@namakemono:/tmp/firefox$ ldd firefox-bin grep c++
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0xb7610000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb67b3000)
Why on earth is upstream’s firefox linked against BOTH libstdc++5 AND libstdc++6 ?!?
Update: Okay, now, with a little more thinking:
mh@namakemono:/tmp/firefox$ LD_LIBRARY_PATH=. ldd firefox-bin grep c++
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0xb75a0000)
And after a bit more investigation, it appears that the gtk module for scim is responsible for loading libstdc++.so.6…
<neli> why does it need so much memory ?After poking around at getting britney to run locally, and doing some basic analysis on how it was used, neli decided to rewrite the memory manager to use chunk-size pools – so that a separate pool would be used for 4 byte allocations, for 8 byte allocations, for 12 byte allocations, etc. That’s possible due to two factors: one is that the special memory allocation is only needed for data structures which are all made from fairly small sizes, and are a multiple of the word size. It also means that fragmentation can be avoided completely – since you can use the “free” elements to store a free list taking up no extra space. Happily, that change also made the memory allocation much simpler. (It also shows the benefits of a fresh look at code; I’d been thinking of doing something similar for ages, but always been stopped because I couldn’t figure how to make it cope with the various different sized blocks I’d need. As it turned out though, I’d solved that problem ages ago when I wrote a separate allocator to deal with strings, which would’ve required my malloc to cope with a much larger variety of sizes) What it didn’t do was actually solve the memory leak. Which was pretty confusing, since the old memory checker had some tests to ensure that memory wasn’t really being leaked, and if the memory’s not being lost due to a missing free, or being lost to fragmentation, where is it going? At this point, the real benefit of having a simpler malloc implementation came across; because suddenly it was plausible to add some debugging code to allocate a separate pool for every memory allocation, and to report how much memory is being used at any point, per line of code. That gave me output like:
<aba> neli: because it needs to check how the changes affect the installability count
<neli> aba: ok…but still does not seem like a big deal
<neli> how large trees are we talking then?
<aj> it has to do a lot of backtracking
<aj> how large is the longest dependency tree in debian?
<neli> backtracking only takes time, not space, right?
<aj> you need a list of things to backtrack over
<aba> neli: it also consumes memory, at least with the current dpkg-implem ntation
<aba> (well, there are ideas how to avoid this memory fragmentation, but that’s something else)
<aj> (it’s not actually memory usage, it’s memory fragmentation)
<neli> hmm, bad memory manager ?
<aj> imperfect, *shrug*
pool 8B/1:751; 1962683 used 1965960 allocated (99.8% of 22 MiB)So I knew that line 751 (of dpkg.c), was allocating 8B chunks, had used up to 22MiB in the past, and was currently using 99.8% of that. (Actually, I made an off by one error initially, so the “8B” above is actually 12B, as you can see if you divide 22MiB by 1965960) That let me see two “leaks”. One turned out to be fairly easy to diagnose; as an optimisation, when I say “package foo is installable”, I note that “but we used bar to see that, so if we later update/remove bar, note that we’ll have to see if foo is still installable”. So the datastructure for bar ends up with a linked list of all the packages, foo, that relied on it. But I don’t check that list for dupes, so if I note that both bar and baz were required for foo to be installable, then update bar, when I recheck foo, I’ll add it to both bar’s and baz’s lists; which is fine for bar, whose list I cleared when I updated it; but not so fine for baz, because it’s now got two entries for foo. Having already added a check for dupes when trying to see if my guess was right, extending that check to skip the addition was pretty easy. The other leak required a little more investigation. It was in a fairly tight loop which could reasonably be using a fair amount of memory; but by the end of the loop it should all be freed. Adding some more debug code to the allocation functions confirmed the problem:
<aj> pool 8B/11:1231; 1618157 used 1703936 allocated (95.0% of 13 MiB, 9.05% current)The code was meant to either add the allocated block to a larger list that’s being traversed, or to free it immediately – the problem turned out to be that there were some nested ifs, and an internal if was lacking an else that should have freed the block. Fixing that changed the results to:
<aj> so it looks like ~9% of those allocations are never freed to me
<aj> 9.05% = used/alloc
<aj> where used is incrememnted on b_m, decremented on b_f
<aj> alloc is incrememneted on b_m, never decremented
pool 8B/11:1228; 160 used 131072 allocated (0.1% of 1 MiB, 0.01% current)Which both dropped the leak – only allocating a maximum of 130,000 nodes instead of almost 2,000,000 – and resulted in almost all the allocations that had ever been made, having been freed once britney had been running for even a fairly short while. As it turned out, though, the cure for the first leak was worse than the disease – checking for duplicates in a linked list turned out to take too long, and the memory wasted in that section wasn’t that big a deal. Using a red-black tree or similar instead would’ve been a solution, but so far doesn’t seem necessary. There haven’t been any OOMs since, happily; and even better, the reduced bloat seems to have made the overall checking a bit faster. Sweet.
):
#define MSG_WINNER "The computer is your friend. Trust the computer"#ifndef DISABLE_HUMORif ((time(NULL) % 100) == 0)addreply_noformat(0, MSG_WINNER);#endif
echo 'something\c' over echo -n something when both ‘\c’ and -n are understood by echo.
The second issue is that when giving some options with spaces to configure (like in --enable-optimize="-pipe -w -O2"), the associated variable gets backslashed spaces (i.e. "-pipe\ -w\ -O2") (thus, being an autoconf feature)
The third issue is that the mozilla configure.in script tries to get rid of these backslashed spaces with echo $enableval sed -e 's \\\ g', triggering the nasty dash bug. A simple workaround, as stated in #256384 is to quote $enableval
Now, for the dash bug itself.
What happens with dash is that whenever you echo a ‘\c’ escape sequence, all subsequent echo commands stop printing after the first argument containing a backslash. For example echo test1 'test2\ttest3' test4 outputs test1 test2<tab>test3.
In the case of our echo $enableval, since its value was -pipe\ -w\ -O2, it printed -pipe\ without any space after the backslash, so that it was not removed by the sed call. This value was then substitued in config/autoconf.mk.in to create config/autoconf.mk, where the ending backslash was interpreted as its shell meaning (continue on next line), thus breaking the variable, and build command lines.
And for the bad programming practice ?
The dash bug is due to a global variable that never got re-initialized, leaving the “terminate echo” (kinda) flag turned on (which is only checked when there is a backslash in the argument, since it is used to stop printing after, guess what… ‘\c’).
No wonder why one of the first things you learn in programming classes is : never use global variables. (or at least, be very very very careful about what you do with them)
First there was Debian Planet then along came the Planet Debian, unfortunate naming collision, but something we could mostly get used to and understand. If you’re not confused yet: well done. You soon will be: Guess which site that is? A third completely new name comprised of the two words “Debian” & “Planet”. WTF? Think that was fun? Lets try again. Stick with me: First there was Debian Help - now there’s another new site which is comprised of the two words “Debian” & “Help”: *Ugh* Now I’m personally of the opinion that competition is a good thing, but please people - can we all just get along without confusing our users/visitors? I’ll sidestep the whole trademark issue, in case my site is in trouble too![]()
Next.