Search Results: "zed"

23 November 2005

Antti-Juhani Kaijanaho: Fun with the new CD/DVD burner

Yesterday, I finally set up my new toy (_NEC DVD_RW ND-1300A, ATAPI CD/DVD-ROM drive). Immediately tried debian-installer on the secondary machine. Found out it does not boot from CD. Spent hours considering flash BIOS update (the BIOS is from 1992...) and writing a small boot assistant that would fit on a floppy and simulate a proper CD bootup. Eventually found out about Smart Bootmanager, which was godsent. After lots of problems with floppy booting, I finally got debian-installer to boot from the CD-RW-simulated business card but saw it froze at loading RAMDISK. Realized the machine has only 24 MB of memory. Decided to try again with the primary computer. Tried installing sarge on the secondary disk (with the primary disconnected to prevent any collateral damage from bugs and misuse). Looked awesome, but there were problems. Since it was 5AM at that point, I went to bed. Now trying to persuade the secondary computer to boot from stable boot floppies. Fun!

21 November 2005

Daniel Burrows: A type-system hack

WARNING: nothing in this post has been implemented or tested, except maybe at a minimal proof-of-concept level ("it compiles!"). It's just some musings on how you can make the computer do your work for you.

I was reading a defense of Hungarian notation when I started to get a familiar notion tickling the back of my brain. The author was explaining that the original idea behind Hungarian was not to replicate type information in variable names, but rather to include some sort of usage information: one example would be giving a string value holding a value that is untrusted the name utName. While it's more reasonable than lpschwzMyVariable, this suggesion made me suspicious that the author was really hacking around suckiness in the C language.

Tagging values with usWhatever and then verifying that you never mix usBlah with Blah isn't just tedious and error-prone, it smells a lot like doing work by hand that the computer ought to do for you. It seemed to me that it ought to be possible to "tag" unsafe values at the type level and let the language's type-checker sort things out. The simple approach is of course to define something like this:

newtype Unsafe t = Unsafe t


NB: I'm using Haskell because it was the first language that sprang to mind when I thought "type system hack".

This newtype declaration lets you attach an Unsafe tag to any type. Presumably the type signatures of routines that return untrusted data (such as a hypothetical getHTMLFormValue or a routine to retrieve previously entered form values from a database, if they aren't sanitized first) should be modified; for instance, if the signature of getHTMLFormValue was

getHTMLFormValue :: HTMLForm -> String -> String


it should instead read

getHTMLFormValue :: HTMLForm -> String -> Unsafe String


To create a new Unsafe value you simply apply the Unsafe constructor to the value:

getHTMLFormValue = Unsafe (oldGetHTMLFormValue)


To unwrap Unsafes you use pattern-matching:

let (Unsafe unwrapped) = wrapped in ...


So, this sort of works, but it's unsatisfying on several levels:



While it may not be perfect -- it only makes sure that you don't accidentally violate safety, and doesn't stop you from deliberately doing something dumb -- this approach feels a lot safer to me than ad-hoc mangling of variable names. I used Haskell because you can do type hacks fairly easily in it, but I don't see why you couldn't play a similar game (albeit much less conveniently) in C++, or even in a dynamic language like Python. Of course, Python would give you runtime errors about safety violations instead of static ones, but that still beats getting runtime security holes.

I would add as a hypothesis that it should be possible to express just about any variable-name-mangling technique whose goal is to "make wrong code look wrong" in the type system, provided your type system doesn't suck; and that doing so is preferable to doing it manually, since it means that a lot of repetitive error-checking can be handled by the computer. And since the computer is better than you are at verifying formal invariants, forcing it to handle them whenever possible is always a good idea.

20 November 2005

Gunnar Wolf: ...So we did it!

Note: When reading this entry, please set your date to 2005-11-10. Delays in the system prevented me from posting this earlier.
I have lived together with Nadezhda for almost ten years - And this month (on November 1st, to be precise), it is ten years we first met on one of the few BBSes we had in Mexico by then - Thanks a lot, Mag, for setting it up - you changed my life in more ways I'd ever have thought!
Over the time, of course, our relation has changed a lot - the first step was telling to other people about each other's existence. The second was accepting we were not together only in between (long story... But I was about to leave the country for good. And I did. But then she followed. And we came back together). Then, little by little, we started settling down, we became a formal couple in the eyes of our families and friends.
We always thought social conventions were silly. We laughed about the prospect of marriage, of having to accept in front of others what we felt towards each other - But anyway, some months ago, we started talking it would be nice to make out of our nice, private relationship something serious and formal to commemorate our ten year anniversary.
Not much was told about it for some months... Until by mid-October we realized we would not make it in time if we didn't hurry - So we went to the Registro Civil at Coyoac n and asked for an appointment with the judge. November 1st is an official holiday, so it was not possible to make it right on the same date - We got the appointment for November 9.
Some people might be asking here why weren't they told about this - Well, first of all, as you can see, we didn't have much time to plan this. Second, we decided to take this formal step, but to have it privately. We went only with my father, my brother, Nadezhda's mother, sisters, our nephews and one long-time friend. We were summoned at 10:30AM, had to wait for the judge to marry some other couples until around 12:00PM, had some nice words from him for ~15 minutes, and went for a nice breakfast in a nearby restaurant with the whole gang.
Oh! Something interesting: We actually didn't know when we were formally getting married. We were called some 30 minutes before the official words to sign some papers, which the judge would later, and privately, certify as valid. The judge just talks, he does not sign anything with us present... But, well, it is a nice moment ;-)
And... Well, here is the proof. It took some days to receive the document, it took me some more days to finally post about it - But finally, our acquintances have been informed of our formal step towards a life together :)

Jose Carlos Garcia Sogo: 20 years of MS Windows. 20 years of computers in my life.

One day like today, 20th November, 1985, Microsoft released its shiny new Windows 1.0 which was the first attempt to implement a graphical multi-task OS in a PC. Do you know how much it cost then? $100 for a license, more or less the same than a Windows XP license costs nowadays.

Microsoft logos. Old and new It is funny to see how things have evolved since then. Being 6 at that time, and PCs not being very common those days at home, I started using a computer at an age of 8 or so. It was an Amstrad PCW 8512, a TV box sized computer which integrated a green screen monitor, two "3" floppy bays and a 9-pin dot matrix printer. It was powered by a 8bit Z80 processor, running at 4MHz and had 512KB of RAM and no ROM at all. Main software was LocoScript, a powerful word processor. It could be controlled by drop down menus at a top toolbar, and initial screen was a file manager, in which you could manage those text files in the floppy you booted from or a floppy in the other bay. It had even support for some kind of multiuser support, as you could declare in each floppy up to 7 user areas, with area 0 being a common root. Also, it had support for limbo a place for deleted files. Although LocoScript didn't need a separate OS to work, CPW 8512 could also run CP/M OS, which added programming capabilities (Maillard BASIC) and support for spreadsheets and databases, along with some games as Batman. After using this system for a long time, my first PC was a 486, running the new Windows 3.1 and later 3.11 for Workgroups version. I even installed there a Windows 95 when it was released, and managed to create a partition in the only 170MB HDD it had to install a test copy of IBM's OS/2 Warp that came in a CD bundled with PC World magazine. Some time later my parents bought a Pentium 166MMX running Windows 95. I was 18 by then, it was 1997, Internet was starting to be widely spread and used, and after a couple of months at University I was installing my first Linux copy, which was a RedHat based version. During next three years I installed different distributions, as they were released with newer software and you could get them in a CD with a magazine. Installing Debian Slink and having an Internet connection available at my Student's Residence at the same time made me be able to participate in mailing lists, send bug reports and download upgrades. I discovered a new dimension in using Linux: collaboration.

19 November 2005

Erich Schubert: Bug hunting on SELinux

I've been trying to track down an annoying bug with SELinux these days. The situation is as follows: when I'm running enforcing mode, binds' "host" command, "named" itself and "dig" won't work. They fail with an odd error message: mem.c:653: INSIST(ctx->stats[size].gets > 0U) failed. or with the latest bind backported to stable: host: isc_taskmgr_create: no available threads the SELinux audit error reported is denied execmem for pid=28566 comm="host" scontext=root:sysadm_r:sysadm_t tcontext=root:sysadm_r:sysadm_t tclass=process. As far as I know, "execmem" means the process can do runtime code generation (i.e. make its own memory executable) - that is a privilege you don't want to give out lightly. But everybody should be able to use the "host" command... so the situation sucks. Right now I guess that this is caused by pthreads, not bind itself. Anyone some hints for me? Does this mean I have to build a customized libc to run stable with SELinux (or make huge modifications to the policy, to add a domain for "host" and exec permissions to every other domain that needs to be able to run "host"...)?

16 November 2005

Jaldhar Vyas: Top 20 Geek Novels

I have read 13 of the books on the list that Clint mentioned. I had begun to write about all the ones which I expected to be there but weren't and then realized I might as well make my own list. So here it is in alphabetical order not in any particular rank. Some entries are actually series. All pretty damn geeky I think if not stereotypically so.

Ian Murdock: Small pieces down the software stack

John Carroll:
[T]echnology across software domains should be consistent. There should be a standard, however de facto, that works everywhere. Skills should be portable across those markets, so that someone with experience in desktop software development has a decent chance of developing for handhelds. Everything should just work together, and development across all devices should be relatively straightforward to someone with experience in any one of them. Microsoft has been very good at this. […] I wonder whether the open source world can match that consistency. Granted, there are movements to make things consistent, such as the LAMP set of technologies for Linux, or the Linux Standard Base project. However, the structure of development for open source products militates against the establishment of any consistent standard. Open source development relies mostly on voluntary contributions. People don’t tend to contribute to ALL open source products (that would be impossible). Rather, they concentrate mostly on the products that interest them. This results in a developer version of tunnel vision. Since all that matters is the creation of the handful of products to which the volunteer contributes, what matters is the interests of contributors to a single project, not the interests of technology which should span ALL products.
Great points, though I clearly disagree that the open source community is fundamentally unable to match Microsoft on providing a consistent environment. It’s going to take some work on our part though. One of the reasons Microsoft has historically been so successful is its unique ability to integrate disparate technologies into cohesive wholes, as well as to leave the mechanisms they use to do this just open enough that others can integrate with them to a degree but never so open that they can do so better than Microsoft can. Of course, Microsoft can do this because they develop, own, and control each of the pieces and the interfaces between them. Other platforms (Linux, Java, UNIX, even the Web to a certain extent) are comparative mishmashes for the exact reasons John describes, namely that every project is developed independently, and that there’s comparatively little thought put into how the pieces interact. The only parties that do think about these issues, the Linux distributors, tend to do so after the fact, and, of course, they have no direct control over the projects that produce the pieces to push any integration improvements they might make upstream (in the general case anyway). Furthermore, once multiple solutions in a given problem domain emerge, it’s not always possible to generalize the interfaces when the projects behind them don’t agree with each other on the “right solution”. In other words, because it’s an after-the-fact thing, “not invented here” and general inertia come into play. So, while the technical aspect of the problem is important, namely the interfaces between components (APIs at the source level and ABIs at the binary level), there’s a social aspect here too. We need to encourage the kind of competition at the implementation level that results in technical excellence while fostering a sense of cooperation at the interface level to ensure that, collectively, the various implementations fit seamlessly into a larger, consistent environment. In other words, we don’t want to get in the way of open source project and Linux distro innovation, but we do want to encourage open source projects and Linux distros to innovate in a collaborative fashion so the technology that ultimately wins in the marketplace can be standardized with as few legacy issues as possible (or, in the case where multiple best practices emerge, for legacy reasons or otherwise, we want to collaboratively define a uniform interface, i.e., cooperate on interface, compete on implementation, etc.). That’s the only way we’re going to get there.

14 November 2005

Gerfried Fuchs: Merry X-Mas

I know, I know. A bit early, you might say. But let's face it: The shopping industry is already fully into christmas. You already get advent calendars, christmas cookies and thing in the various stores. And I got my first christmas presents the last week.... First of all I finally tried again to switch to Linux 2.6. Going through the great amount of options in my make oldconfig from 2.4 I finally tried to boot with it. The most deep changes I did was: This was my own christmas present. But I got some more, from a dear friend whom I'm working with and helping from time to time. More in a funny way I sent him a christmas wishlist, but he took it serious, and so there I am. Like, with a Gameboy Advance SP Kingdom Hearts Edition, including the game. I really loved the first part on my Playstation 2, am desperately waiting for the second part which shall be released in europe in spring next year... *sighs* The second major part was a Typhoon My Mini DJ music player. Most important thing for me with it is that it plays oggvorbis files natively. Finally I'm not the only one without a portable music player! Last but not least I'm going to attend LWE in Frankfurt/Main, and finishing my LPI Level 1 certification there. I'm not too worried about the test, though it for sure will be a good feeling to finally have something written and not only you lot telling me that I have some knowledge about it.

Ian Murdock: Small pieces loosely joined and Web 2.0

Om Malik: “[O]n this Web 2.0 highway, there are three exits: Microsoft, Yahoo and Google.” That’s a clever soundbite, and perhaps it’s true from the venture capitalist’s point of view, but I think it misses something fundamental: That the real attraction of the new web platform is that components don’t have to be rolled up into one big monolith anymore to integrate well with each other. We’re entering into a world where lots of little, independent component providers will be able to coexist and thrive alongside the platform vendors. Why? The platform vendors no longer have such a chokehold on distribution that the best the component providers can hope for are a few years of prosperity before the platform vendor notices there’s an interesting little market emerging around a particular component, integrates the component into the platform, and renders the independent component unnecessary. In the old world, a component provider’s prosperity was often its ultimate undoing. I’ve always sympathized with the platform vendors’ (OK, Microsoft’s) argument that this kind of integration is done in the interest of customer convenience—I for one don’t want to buy an operating system only to have to go out and source my own, say, memory management and data compression components (something, if you remember, we had to do in the MS-DOS days). In the old world, that probably meant going out, buying more software, and dealing with the headache of getting it installed and integrated. It was simply more convenient for the customer for the popular components to find their way into the platform, integrated and ready to go with no assembly required. In the new world, though, sourcing a component is no longer a heavyweight operation. By and large, the components themselves are free, and thanks to open APIs and data formats like RSS, it’s now possible to integrate those components into larger applications with comparative ease. Granted, the applications of today are largely ad hoc “mash ups” without an intermediating platform vendor in the traditional sense, but it won’t be long, in my view, before vendors step into that role and make writing such applications as systematized an operation as, say, writing an application for Windows or Linux is today. Yes, Microsoft, Yahoo, and Google are probably those vendors. Yes, the component providers probably hook into their platforms as the primary vehicle for monetizing their wares. However, without the same level of control over distribution that the old world enjoyed (not to mention the proliferation of open APIs and data formats), the big guys will have to coexist with the little guys. The platform vendors will compete by providing the most compelling incentive to the component providers. In old world terms, the platform with the most ISVs will win. This bodes very well indeed for innovation in the new “Web 2.0″ world. Above all, the days of the platform vendors integrating all the components into the platform to the exclusion of independent providers have come and gone. Thankfully.

13 November 2005

Matthew Palmer: Snail Racing (The Legal System)

I previously mentioned in a sidenote to another post that I've been involved in a court case over the last few weeks, and I promised a few people I'd blog about my adventures there. Obviously, not quite everything can be discussed in an open forum, but I checked with the legal beagles and I'm OK as long as I stick to generalities. Which is fine by me, since the detailed specifics are actually immensely boring. Executive Summary: It's the law Jim, but not as the TV shows it. I have to recommend that everybody spend a bit of time watching a case or two at their local court. It's surprising how different reality is to what you see on TV (of course, Australian courts are going to be different to the US courts we primarily see on TV, but even the dramatic representations of Australian courts I've seen are fairly inaccurate). The legal system, while appearing to be out in it's own little world, is a vital and integral part of most societies, so it's useful to have at least a basic idea of what goes on in them -- not because you'll end up in one (and even if you did, your lawyer will tell you what to do) but because it's an interesting insight into a part of our world that often affects us, but we don't like to look at. (Going and watching your houses of parliament, or an abboitoir, is a similar thing). Second, if you can possibly avoid it, don't get involved in a case. Not as a defendant, not as a litigant (in a civil case), and not as a witness. Litigants and defendants get screwed because they're stuck in a small room with a bunch of people they don't know or particularly like, for days or months, with a limited understanding of what's going on. Boooooooring. For witnesses, it's a different kind of pain. But I'll leave the details of that for another post. One of the things that quite surprised me is the general good nature and decent relationship between all of the legal professionals involved. They're willing to help each other out, they concede points graciously, and there's a surprising amount of banter between all of the lawyers and (in some cases) the witness as well. I'm told that this was peculiar in my case because I was involved in a voir dire[1], and everyone's on their more formal behaviour when there's a jury in the room. At times, it was almost a pleasure to watch the proceedings -- like a slightly dry but nonetheless compelling play. Most of the time, though, I characterised as "Snail Racing" -- about the most dull activity one could imagine, but nevertheless you just can't tear your attention away in case something interesting happens while you're blinking. When I say that the lawyers are good natured, that's not to imply that they're not vehemently arguing their case. Toward the end of the voir dire, in particular, counsel for the defence started to get rather vocal as to the lack of proper procedure on the part of the Crown. Over the entire voir dire, too, both counsel were always pressing hard and always trying to get their case seen in the best light. But their vigourous pursuit of the case never got personal or competitive. I think that's actually something that a lot of free software people could take on board (myself included) -- argue strongly for your position, but never internalise it or make it personal. Your position may be rather important (the defendant in my case was looking at up to 14 years if he got sent down) but making it a personal attack isn't going to help your case. I was amazed at the speed with which counsel picked up on new concepts and ideas. Unsurprisingly, the expertise I provided was quite technical, and counsel were not particularly computer literate. However, over lunches, I was able to essentially brain dump fair chunks of knowledge at the barrister, and he then went inside and laid it all out, usually accurately and very good presentation. It's also intensely satisfying to know that the questions that are being presented were suggested by you, and the skillful way that the ideas and queries were weaved together. I guess you'd get a similar buzz writing a play and then watching skilled performers bring it to life -- not necessarily exactly the way you imagined, but with an undeniable skill and vibrance. I've got a lot more material about my adventures in the legal system, which I'll be posting over the next while, but I figure this is probably well enough to be going on with for now.
1. A voir dire (as explained to me) is a sort of "trial within a trial", used to determine a point of fact or the admissability of a particular piece of evidence. It is run in the absence of a jury. They're only supposed to run for a couple of days; apparently mine was extraordinary at three weeks, although mention was made of a six week marathon (in the context of "this better not be like $OTHER_VOIR_DIRE").

12 November 2005

Christine Spang: Mutt sucks less

So, I’ve recently switched to Mutt for mail-reading purposes, and aside from it taking a motherload of all time to get all the necessary parts setup and configured properly having never done it before, I am so far extremely happy. It looks like it’s going to be a huge timesaver overall once I have everything tweaked to my liking. Yay for Erinn giving me her super muttrc file which was incredibly helpful and neato. (Though I’m still tweaking the display colours in it: I agree, helix, I don’t like yours. :-p) All I need to do now is get my spam filtering setup in both procmail and the necessary hooks in Mutt, and add a few macros of my own. (And finish fleshing out my aliases.) Oh, and I need to fix some of my procmail rules, probably to sort by List-Id instead of ^TO, because I believe many of these lists are using bcc or something which breaks my list filtering. I haven’t looked at it too much yet. One of my friends gave me lots of digital pictures from various things: Home-brewed Halloween fun: I was traumatized that I forgot my cross at home. I also apologize for any trauma caused by this picture. (Yes, all three of us are indeed girls.) Edit: added in proper image thumbnail to not be evil.

Erich Schubert: Mathematics and CS forums for LMU München

If you are a student of mathematics or computer science in München, visit Die-Informatiker.net or Die-Mathematiker.net, which are two pretty nice forums for our university. The latter is new, the first has been successful for several years now, and is officially "recognized". So you might even get answers from your TAs in there.

10 November 2005

David Nusinow: Modular Server Debs!

I've been relatively quiet lately because I've been plodding along, working on modular packages for Xorg. For those who don't know, the next release of Xorg will actually be two releases of the same code. One release, 6.9, will be based on the old monolithic build system. This system requires me to build every single part of Xorg whenever I want to update any one part. This means that whenever I push out an Xorg fix, no matter which component it's in, you have to download all the other components even if they are 100% identical to the previous version already on your hard drive. We've all lived with this for a long time, and while it's not pleasant, we all seem to get by. The packaging apparatus for this system is mature, stable, and well understood, if complex. That's why I've been able to get the 6.9 release candidate packages out to experimental fairly quickly after they are released.

The other release happening is for 7.0, which is obviously a major version number bump. The actual code you run for 6.9 and 7.0 is 100% identical, but the build system has been totally rewritten around the venerable autotools (you know... configure /make/make install). Each piece has been split out from the others so that you can build any one component without building all the others. This means that if we want to ship a driver update, you don't have to download all of the fonts and other things that weren't touched. That also means that you won't have to install the drivers for cards you don't own if you don't want them. Furthermore, it lowers the barrier for things like hacking on X significantly.

The problem with the modular tree is that the packages for it are brand new. Ubuntu shipped modularized versions of the libraries, and I've already stolen those, fixed them up for Debian, and built them locally (they're sitting in our svn repo, but running them won't get you anything at this point.) The server and driver packages are brand new, and I've been taking the packages from Ubuntu's development branch and working on them for Debian. Today was a milestone day because in addition to the libs, with Daniel Stone's constant help I've finally managed to build packages for the modular X server itself. Now I can't run it yet (I haven't packaged the drivers and a few other bits) but the fact that I managed to produce what will be a functional server package is a huge step, and constitutes the cornerstone of the whole thing.

Once we can create packages that can actually run on at least the machines of the XSF, we can start looking at getting the packages in to the archive. Since these aren't well tested like the monolithic packages, we'll have to do a lot of polishing to get them to the same level of quality. My goal is to get that done for etch though, and I think we can do it. Exciting things are happening, and I'm hoping that the modular packages will encourage more people to hack on X, leading to even more exciting things. Build that momentum.

9 November 2005

Junichi Uekawa: assembly output for x86_64.

I compiled a C program which just gives out 'hello world', and analyzed the gcc assembly output.I suppose subq/addq for rsp is for int parameter; or it couldbe an ABI requirement.It is surprising that pointer is movl'd to edi (32-bit) forthe puts parameter.To set eax=0 (for the return value), xorl (32-bit) is used.I wonder what happens to the higher 32-bits.Maybe it's time to seek for the CPU reference.

7 November 2005

Antti-Juhani Kaijanaho: Klingon Hommey

As I wrote earlier, I am trying to learn the Klingon language. Today, I caught up on Planet Debian postings and saw one of my fellow developer's name in a completely new light: Hommey is interpretable as Klingon. Hom means 'a bone', and -mey is the general pluralizer. Normally Hom would be pluralized by -Du', because it's a body part, but when -mey is used, it implies that the bones are used not as parts of a body but in some other usage (as weapons or something like that). In a poetic context, Hommey can also mean bones scattered all about.

Adam Rosi-Kessel: Plamegate Summarized

Following up on last week’s excellent interview with Brent Scowcroft, the New Yorker featured a well written and thought provoking article on the Valerie Plame Wilson affair this week. The article doesn’t necessarily break any new ground, but it’s the best summary I’ve seen so far of the scandal. If you haven’t been following every twist and turn day by day, you’ll probably learn something new. Even if you have, the article puts the whole thing in perspective in a way I haven’t seen elsewhere.

5 November 2005

Anthony Towns: Britney's Memory Management

One of the things about the whole money thing and free software is the question of whether it’ll take all the fun and spontaneity out of hax0ring. As it turns out, that doesn’t even work when you try; so instead of doing dak work last weekend, like I’d planned and like the market was indicating, I ended up hacking on britney until about 5am Sunday morning, leaving the dak stuff to be spread over the week, instead. (After the last post, dak might seem cursed, but trust me it’s not. More on that RSN, but not just yet) For those playing along at home, britney is the name of the scripts used to update Debian’s testing distribution; basically it automates some of the hard problems of Debian release management. Naturally, this is a pretty tricky job – there’re over 200,000 packages in Debian unstable (spread across eleven architectures), with fairly complicated sets of interdependencies amongst them. It gets complicated enough, in fact, that the core analysis britney undertakes isn’t just too processor intensive to do in perl or python, it’s too memory intensive to use standard malloc for its data structures. (Cynical and Coding, and the UQ CS228 class of ‘98 will probably have some idea of the fun to come at this point…) The problem is that britney uses an absurd number of linked lists to resolve dependency issues, with each entry in the list being an independent block of a dozen or so bytes; and adding the usual malloc overhead to this can effectively double the memory usage. Worse, britney also likes to reuse memory quite a lot, does a fair bit of backtracking, and generally acts like the prima donna she is. Up until last week, britney’s memory was managed by the use of a parallel bitfield indicating whether memory was free or not: so britney would first allocate a 128kB block using standard malloc, note it’s all free, then every request for 12 or 52 bytes would result in some bits being twiddled; and every free would twiddle the bits back, so they could be reused later. This means two things: one is that the free invocation has to include the size of the memory to be freed as well as the address, and the other is that finding an appropriate sized block of freed memory can be awkward, leading to some degree of fragmentation. This fragmentation seemed to lead to britney having a gradual memory leak, which would mean that if the release managers were doing some complicated transitions gigabytes of memory would end up being used and OOMing; or, since britney runs on ftp-master and it’s probably not a good idea to have the OOM killer start on the machine that ensures the Debian archive’s integrity, the ulimit is reached, and britney aborts unhappily. Unfortunately, though, the use of a “roll your own” malloc means you can’t use the standard memory checkers to see what’s going on, so you’re left with guessing and hoping. And as a consequence the memory leak’s been around for ages, causing fairly regular minor annoyance. This changed last week when Micha Nelissen (neli) got into the act:
<neli> why does it need so much memory ?
<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*
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:
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)
<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
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:
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.

Mike Hommey: Nasty bugs

Recently, I’ve been going through mozilla-firefox’s list of bugs and took a look to some of them. I got interested in #336411, since I’m regularly hit by this one myself (remember ? I said I got strange crashes with 1.5beta1). It appears that this strange crasher is in fact due to extensions using binary components. ColorZilla was the one killing my firefox. Why does it crash on debian’s firefox and not on upstream’s ? Simple : upstream’s is built with gcc 3.4, debian’s with gcc 4.0. Both C++ ABIs are incompatible. Now the question is : what can we do for that ? A quick fix could be to check before loading the component, if it’s linked to the incompatible libstdc++.so.5, but it’s almost as nasty as the bug itself… I’ve not really investigated possible solutions yet, but if you have some better ideas, you’re welcome. Another bug I got interested in is #211010 and its dupe, #256384. This one was really nasty. One of the kind I hate : bad programming practices. The interesting thing with this bug, though, was that it’s been revealed because of 3 other issues in 2 separate programs. The first issue is that autoconf decides to use 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)

2 November 2005

Martin Michlmayr: Kyoto, Osaka, Japan Debian Mini-Conf (JDMC)

On Wednesday I got up way too early in order to go to Heathrow in time for my flight to Osaka. The flight went via Frankfurt and wasn't terribly spectacular. I was a bit disappointed in the flight entertainment system (only shared monitors in the middle of the plane, mostly showing movies I've seen before) but I had Hodges' biography of Alan Turing with me and slept for a while, so it wasn't a bit issue. Arriving Thursday morning, Yabuki-san, who had originally invited me to the Japan Debian Mini-Conf (JDMC), picked me up from the airport. Shortly afterwards I met up with Imai-san, who was so kind to go sightseeing with me in Kyoto. I wanted to go there because I heard that it's quite different to Tokyo, where I stayed for about 10 days for a conference three years ago (incidentally, that trip was in October too, so it was three years ago almost to the day). Kyoto was surprisingly close to Osaka — it was faster to get there than to go from Kansai airport to the city center of Osaka. We first went to Nijo Castle, followed by some temples, including Kiyomizu-dera, one of the most celebrated temples of Japan. We had sushi and noodles for lunch, and in the afternoon we returned to Osaka so I could rest for a few hours before meeting up with the interpreter of the conference. This we did at a restaurant specialized in tofu. The food was surprisingly good given that I'm normally not a big fan of tofu at all. The following morning, I had my keynote speech, talking about release management. I covered various insights learned from my research and then tried to apply some of them to Debian, asking the question whether something like time-based releases would make sense for the project. A big issue is obviously planning, and I think the new release team does a much better job at this than we did in the past, even if many improvements are still possible, such as better coordinated NMUs when major transitions take too long. All of the other talks where in Japanese, so I was either working on my laptop or walking around the city. The first day, Hatta-san and I went to Osaka Castle; Roland Mas, who briefly turned up for the JDMC, joined us as well. The second day I did some shopping before going to the conference where I participated in the key signing session. On Sunday morning I had to leave again... it was a nice trip, even though much too short and influenced by jet lag. I think there could have been more people at the JDMC but on the other hand it's nice to see some efforts to attract new developers in Japan and this conference was certainly a good first step in that direction.

Jaldhar Vyas: Going to Bangalore

Branden has authorized funds to cover my travel expenses and I've booked a ticket so it's official. I will be attending foss.in

Next.

Previous.