• SoC 2008 Mentor Summit

    The Google SoC 2008 Mentor Summit is now officially over. The summit has taken place during the whole weekend and has been pretty intensive. The organization of the whole event has been excellent thanks to the hard work of Leslie Hawthorn among others; sorry, can't remember your names... I'm very bad at this.We have had multiple sessions, ranging from technical ones such as distributed version control systems to more political ones such as how to deal with assholes in open source projects. There were lots of passionate people in these talks, and it was quite interesting to see it all. The cool thing, though, as opposed to other conferences, is that everyone here comes from a different project and background, so you get to see lots of different opinions and points of views for each topic.As regards the Google HQ campus, it is great. I thought the NYC offices were good, but these are spectacular to see. Unfortunately, there is not much to do out of them... so I'm not sure if it could be so good to work here for a long time.Now, I'm sitting in the San Jose airport (SJC) waiting for the flight back to NYC. Amazingly, there is free internet wireless connection and electrical plugs! Very, very nice detail. And there is few people around, which makes it very quiet and relaxed.Oh, and to those who will decipher this: some more mini golf training during the summit :P [Continue reading]

  • Live@NYC: ... or not; now in MTV!

    I've landed this morning in San Francisco at 9.00am (which means I left NYC at 6.00am!) and went straight down to the Google Headquarters in Mountain View. No sleep at all except for a little bit of pseudo-sleep in the plane. The Google campus is really nice. It puts the NYC offices in an inferior level than I thought :P But the only problem is that the area surrounding the campus is basically empty. Very small houses and lots of space between them, which is not bad per se... but means that there really is not much to do.Anyway. What am I doing here? I am attending the Google Summer of Code 2008 Mentors Summit this weekend, but came a bit earlier to be able to do a couple of meetings with coworkers in the Mountain View office. Pretty exhausting day, and it is not close to over yet!Just enjoy the few photos I've taken so far.PS: Been playing mini-golf on-board until I got an unasked segmentation fault. [Continue reading]

  • C++ teaser on templates

    A rather long while ago, I published a little teaser on std::set and people seemed to like it quite a bit. So here goes another one based on a problem a friend has found at work today. I hope to reproduce the main idea behind the problem correctly, but my memory is a bit fuzzy.Can you guess why the following program fails to compile due to an error in the call to equals from within main? Bonus points if you don't build it.struct data { int field;};templateclass base {public: virtual ~base(void) { } virtual bool equals(const Data& a, const Data& b) const { return a == b; }};class child : public base {public: bool equals(const data& a, const data& b) const { return a.field == b.field; }};intmain(void){ data d1, d2; base* c = new child(); (void)c->equals(d1, d2); delete c; return 0;}Tip: If you make base::equals a pure abstract method, the code builds fine. [Continue reading]

  • Live@NYC: Prospect Park

    Yesterday night, we went to a techno club — Webster Hall — which had Carl Cox as an invited DJ. Some of my friends around here enjoy this music and said this was a great DJ, so we couldn't miss it. He indeed was good.Today, after few hours of sleep, I have been doing quite a bit of housework: basically, huge cleaning, reordering and some DIY — had to fix some drawers. Resolving the extremely loud and annoying hissing caused by the heating system will have to wait, though.What I have enjoyed today, though, is spending the evening walking around Brooklyn and, more specifically, in Prospect Park. Central Park is very nice, you know, but this other park is too! Not to mention that the borough (Brooklyn) seems awesome... or at least the few neighborhoods I've visited so far. Much more relaxed than Manhattan and, I've been told, cheaper for living. Anyway, enjoy the photos :-)I guess tomorrow will be, finally, a museum day. Not going out tonight (I'm extremely tired and can't meet my friends) so I guess I'll be able to wake up early and seize the day. We'll see.Note to self: never, never, never again, buy batteries from a crappy deli. They last for a few photos only! Who knows for how long they have been in the shop shelves. [Continue reading]

  • Boost.Process and SIGCHLD

    For some unknown reason, I'm regaining interest in Boost.Process lately.  I guess many of the people who have written me in the past asking for the status of the library will be happy to hear this, but I can't promise I will stick to coding it for long.  I have to say that I have received compliments from quite a few people...  thanks if you are reading and sorry if I did not reply you at all.Anyway.  So I downloaded my code and ran the unit tests under Mac OS X to make sure that everything still worked before attempting to do any further coding.  Oops, lots of failures!  All tests spawning a child process broke due to an EINTR received by waitpid(2).  That doesn't look good; it certainly didn't happen before.After these failures, I tried the same thing under Linux to make sure that the failures were not caused by some compatibility issue with Mac OS X.  Oops, failures again! Worrisome.  The curious thing is that the tests do work in Win32 — but that can be somewhat expected because all the internal code that does the real work is platform-specific.Curiously, though, running the examples (not the tests, but the sample little programs distributed as part of the library documentation) did not raise any errors. Hence, I tried to run gdb on the actual tests to see if the debugger could shed any light on the failures.  No way.  Debugging the unit tests this way is not easy because Boost.Test does a lot of bookkeeping itself — yeah, newer versions of the library have cool features for debugging, but they don't work on OS X.  Hmm, so what if I run gdb on the examples? Oh! The problem magically appears again.It has taken me a long while to figure out the problem. Along the process, I have gone through thoughts of memory corruption issues and race conditions. In the end, the response was much simpler: it all turns out to SIGCHLD (as the error code returned by waitpid(2) well said).SIGCHLD is received by a process whenever any of its children change status (e.g. terminates execution). The default behavior of the signal handler for SIGCHLD is to discard the signal. Therefore, when this signal is received, no system calls are aborted because it is effectively discarded. However, it turns out that newer versions of Boost.Test install signal handlers for a lot of signals (all?) to allow the test monitor to capture unmanaged signals and report them as errors. Similarly, gdb also installs a signal handler for SIGCHLD. As a result, Boost.Process does not work when run under gdb or Boost.Test because the blocking system calls in the library do not deal with EINTR, but it actually works for non-test programs run out of the debugger.The first solution I tried was to simply retry the waitpid(2) whenever an EINTR error was received. This fixes the problem when running the tests under gdb. Unfortunately, the test cases are signaled as failed anyway because the test monitor still receives SIGCHLD and considers it a failure.The second solution I have implemented consists on resetting the SIGCHLD handler to its default behavior when Boost.Process spawns a new child and restoring the old SIGCHLD handler when the last child managed by Boost.Process is awaited for.  Eventually, the library could do something useful with the signal, but discarding it seems to be good enough for now.This second solution is the one that is going to stay, probably, unless you have any other suggestion. I still feel it is a bit fragile, but can't think of anything better. For example: what if the user of Boost.Process had already programmed a handler for SIGCHLD? I just think that such a case shouldn't be considered because, after all, if you are using Boost.Process to manage children processes, you shouldn't have to deal with SIGCHLD on your own as long as the library provides a correct abstraction for it. [Continue reading]

  • Live@NYC: 2 months and a half

    Wow, I haven't blogged for a long time (a month since last post) and I'm already counting down my days in NYC... less than a month and a half left here :-( I certainly miss some things from home, such as the nice little (non-fancy) bars, my bike, the gym, a nice house and, of course, friends and family, but I'm not in a real hurry to go back.So what have been the recent happenings? There are lots of things to tell I guess.First of all, almost all interns are gone. Of all I knew, probably 15-20, only 2 are left, 3 if you count me. This probably means we'll have to look for new friends to grow our partying group a little bit.On another topic, I don't have roommates any more. The ones I had moved to a bigger place and I haven't yet found anyone who wants to share this apartment. The major problem is that the room to be rented is, actually, the living room, so it is hard to convince someone to live here. Lack of privacy is an issue for most even if they don't say so right away.As regards working out, I'm getting way too lazy. It has already been more than a week since I last went running. Will try to force myself to go tomorrow morning again; the food is already starting to accumulate in the wrong places. Somewhat related to this, I've got an iPod Nano 4th generation which, when put together the Nike+ kit, is amazing.And we have got a "new" addiction at work: Guitar Hero. This game is really nice and we are already playing it on the expert level. However, I wonder if it is any good to spend time learning how to play a fake guitar. I'd rather go and buy a real one, and instead spend my time playing real songs. Let's hope Guitar Rising keeps up with the expectations and is published soon; whenever that happens, I'll definitely get it.About more recent happenings, I've been in NYCBSDCon 2008 this weekend giving a presentation on ATF. We'll have the video recordings posted out soon, so be sure to check them to learn some interesting new stuff. It was also a good way to meet well-known people in the BSD world such as, for example, Matt Dillon and Dru Lavigne.As regards work at Google, my project is starting to have decent shape, which means that it actually works! During the next month, I'll have to extend it to some new areas, and that's a bit scary because they'll involve processing vast amounts of data in an efficient manner. (At the moment, the data set is not big enough to really require tuning the code.)Oh, and one last thing about mini-golf. I have played, I think, 4 times already and lost in all of them. This game sucks. Will keep trying, though.I'm missing lots of stuff here, but I don't know how to add more random notes and not end with a completely disconnected post. All the paragraphs are already too independent as they are now. So just wait for the next one to know more :P [Continue reading]