Rote Fabrik is awesome!

Let's get back to blogging a little, now that I have some more time... ;)
Last saturday I went to FrOSCamp 2010 at ETH Zürich (my former college). The conference was quite good with a few interesting talks, but it could have been publicized better, me and a friend of mine just got wind of it by chance thanks to some online article, there was no info-mail to Computer Science students for example, which could have helped increase the turnout...
After the last talk me and a friend, who's just transferred from Lugano (TI) to Zürich to complete his Master of Informatics in Distributed Systems at ETHZ, went to the Rote Fabrik for a night of partying. We choose the place pretty randomly, and since we never went there before, we didn't know what to expect at all. And oh boy, did we choose well! The place is really awesome, it's an old factory made of red bricks (hence the name "Rote Fabrik"), it subscribes to the "alternative" theme, for example to enter you have to climb over the fence. Quite fun! Inside the area there's a restaurant, several bars and several venues for music. The whole place was well kept and very clean, and the food was very good. Normal-to-low prices for Zürich standards.
We first caught the tail of a show by "Tim & Puma Mimi", it's basically a swiss dude playing flute and electronic music, and a japanese girl singing japanese vocals over it; it was... different, but really cool, and they had a few very good songs.
Later the main event was a rock-concert by "The Maccabees" in the big hall, which was really good, but I personally preferred the opening band "Jamaica", they really had some awesome music there!
Getting back home was quite an odissey too, as I managed to pretty much miss all the connections I could miss and ended up waiting around for trains and stuff for hours, need to plan that better next time.
And there will be a next time, as I really was positively impressed by the venue!

Posted by Luca Longinotti on 24 Sep 2010 at 17:44
Categories: Longi Comments



Goodbye ETHZ, Hello UZH!

I've left ETH Zürich behind me, as I really didn't feel their theory-heavy curriculum to be right for me, and I'm now a student at the University of Zürich, following the "Bachelor of Science in Computer Science RO 2008" courses, specializing in "Software-Systems", which I hope will be a much more practice-oriented course.
The first year is together with the students specializing in "Business Informatics", so I also have a few business-related classes, such as Financial Accounting and IT in Companies, which I don't mind, as I find them quite interesting and useful. After the first week I can honestly say I like the place, there's a very friendly athmosphere and I've met a lot of nice and fun new people.

Posted by Luca Longinotti on 24 Sep 2010 at 17:06
Categories: Longi, UZH Comments



Beware of quotes passed to init-scripts!

Just a quick note in case I or others run into this again...
I use Trac to manage a few projects, more specifically Gentoo's www-apps/trac package to ease its deployment. One feature of the package I take advantage of is the init-script to manage the tracd standalone server.
I now wanted to enable authentication for my Trac installs, and all guides out there tell you to add:

--auth="*,/path/to/digest/auth/file,domain"

to your commandline when starting Trac (notice the quotes!), I tried this on the shell, and it worked as expected. I thus changed the TRACD_OPTS variable in /etc/conf.d/tracd to the following:

TRACD_OPTS="--auth=\"*,/path/to/digest/auth/file,domain\"
--env-parent-dir /var/lib/trac/"

It started fine but authentication didn't work at all... Somewhat baffling, but after some investigation, I noticed that the quotes around the --auth argument were passed as-is to tracd, which then failed to find the environment *, since when splitting the --auth argument apart, "* would be used as environment name.
The solution is simply to not set any type of quotes when starting tracd through the provided init-script, so that TRACD_OPTS looks as follows:

TRACD_OPTS="--auth=*,/path/to/digest/auth/file,domain
--env-parent-dir /var/lib/trac/"

In hindsight logical, as the TRACD_OPTS variable gets evaluated only once and then passed to start-stop-daemon, which passes the arguments verbatim to tracd.

Posted by Luca Longinotti on 27 Aug 2010 at 04:55
Categories: Gentoo, Software Comments



GCC's __attribute__ ((nonnull (...))) not helpful at all

Today I encountered some really interesting and disconcerting GCC behaviour...
I'm currently writing a library with some data structures in it, and basically have functions such as the following:

bool queue_get(QUEUE q, void *item);

where item is an address to allocated space on which to operate, this basically is the way you do generics in pure C, using void pointers to memory locations you copy from/store to, based on some size you know depending on your usage pattern.
Now, the first thing any security conscious (and sane) programmer would do is to check that both queue and item are not NULL and act accordingly, either returning false to the user, or in my case aborting completely as I'm of the opinion this is a serious error on the programmers part that he must fix, still I digress, the fact is: there should be some form of NULL check there, for example:

bool queue_get(QUEUE q, void *item) {
    if (q == NULL || item == NULL) {
        exit(EXIT_FAILURE);
    }
    ...
}

This has always worked beautifully. Now the other day I was reading the GCC manual on function attributes and stumbled upon attribute "nonnull", documented as such:

nonnull (arg-index, ...)
The nonnull attribute specifies that some function parameters should be non-null pointers. For instance, the declaration:

extern void *
my_memcpy (void *dest, const void *src, size_t len)
__attribute__ ((nonnull (1, 2)));

causes the compiler to check that, in calls to my_memcpy, arguments dest and src are non-null. If the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. The compiler may also choose to make optimizations based on the knowledge that certain function arguments will not be null.

Note the bold sentence, we'll come back to it later on.
Now, I thought this looked quite useful and changed the prototypes of my functions to accordingly hint to the compiler when I expected a parameter to be nonnull, so for example I changed my queue_get prototype to look like this:

bool queue_get(QUEUE q, void *item) __attribute__ ((nonnull (1, 2)));

And I then started testing this throughly, and was surprised by what I found:
GCC's enforcing of this is more or less useless, it only emits a warning if you pass NULL directly as a parameter to the annotated function, meaning only an erroneous call of the form "queue_get(q, NULL);" would for example be detected, anything else, like "void *p = NULL; queue_get(q, p);" or "queue_get(q, myfunc());" where myfunc() may return NULL, are not detected. There is an enhancement bug open at GCC (bug 17308) to improve it to handle more cases, but it hasn't seen much activity.
Still, I thought even if it was only that one warning, annotating the function this way would surely help and also work as a form of documentation for clients later reading the librarie's header file, so no harm in leaving it there, because the explicit NULL checks inside the library's functions would anyway correctly catch any passed NULL pointer and abort, right? WRONG! COMPLETELY WRONG!
Let's return to that quote from the GCC docs and the last, seemingly innocent line there: "The compiler may also choose to make optimizations based on the knowledge that certain function arguments will not be null.", what this actually means is that at any meaningful optimization level, such as -O2, any NULL-pointer-checks against parameters of a function declared with the nonnull attribute will be simply optimized away silently, so suddenly calling the function while passing NULL during testing always led to a segmentation fault. Whoa, that's somewhat unexpected! And passing "-fno-delete-null-pointer-checks" didn't change anything.
Searching GCC's bugzilla I found bug 36166, which discussed the exact same thing I was observing, marked as RESO INVALID... Basically it boils down to the fact GCC does the detection for warnings and the optimization of code in separate parts, and they don't quite seem to agree, meaning that you only get a warning in one particular case of passing NULL, and even then only if the appropriate warning level and options are set, while it ALWAYS optimizes out NULL checks from the code, resulting in quite broken code. The GCC developers seem to regard this as correct, the reporter disagrees (as do I), comment 7 summarizes the core of the problem quite well, as well as both positions. RESO INVALID makes it quite clear who won the dispute, and in the end we get a mostly useless function attribute that silently completely breaks code, based on a somewhat unclear line of documentation, that was never updated to be clearer (and at least that would have been easy and helpful to do!).
Conclusion: all the __attribute__ nonnull's have been removed from my code again, and what looked like a great idea, completely failed in practice in my opinion.

Posted by Luca Longinotti on 19 Apr 2010 at 21:22
Categories: C99, Programming Comments



Retiring from Gentoo

I'm officially retiring as a Gentoo developer, simply because I've not really done anything in the last year and will not be getting back into the swing of things anytime in the future, so I feel it's time to retire.
It's been a fun 4.5 years, even if I wasn't present much as developer in the last 1.5 years, and I will definitely continue using Gentoo as my distribution of choice, nothing will change that. I've had the honor of getting to know some amazing people during those years, and improve a lot of my skills and competences, and for that I'm grateful. See you all around!

Posted by Luca Longinotti on 02 Apr 2010 at 18:23
Categories: Longi, Gentoo Comments



Happy New Year people!

Happy New Year people!!!
Let's hope for a great 2010.

Posted by Luca Longinotti on 31 Dec 2009 at 23:00
Categories: Longi Comments



Merry Christmas everyone!

Merry Christmas everyone, have a happy time!

Posted by Luca Longinotti on 25 Dec 2009 at 00:10
Categories: Longi Comments



ExpoVina and Sushi

I'll try to blog again more often, so that at least I'll have a log of my life, more or less. ;)

Yesterday (Tuesday) evening I and a couple of friends (Flavio, Andrea and Dersim) went to ExpoVina 2009 in Zürich, a big wine exposition held on 12 boats anchored at the Bürkliplatz port.
We arrived at around 1700 and stayed till about 1920, sampling wines from different countries, regions and producers. I particularly appreciated the selection of sweet wines from Bindella, as I love sweet and dessert wines, and ordered a few right away, their VinSanto "Dolce Sinfonia" and the "Brachetto d'Aqui" were incredibly good. We also sampled a few wines from Valais, Switzerland, (Favre, Dubois), which were quite good, but I didn't order any of those, as they are relatively easy to find here, and I actually know the Favre Caves in Sion personally, as I was there with the military during my Fourier advancement course, and later with my father. They make quite good white wine, such as the Petite Arvine. Being a fan of sweet wines, I also couldn't resist ordering a few bottles of Samos, a very sweet Greek wine, by Keel. We also had our first taste of Spanish wine, from Casa del Vino, they were quite different from the usual Italian wines we were accustomed to, but quite good nonetheless. The people manning the stand were also very polite and helpful, telling us the differences and histories of the various wines as we sampled them, and offering us samples from all regions and types of wines they had. One of the friends with me then told us another guy we know (Simone) already was here a few days ago, and recommended to try the Port wines from Amarela, which we did. Most of us had no particular experience with Port wines at all, so the guy there helped us choose, and we all were pleasantly surprised, ordering a few bottles of Ruby Reserva and Finest Reserve. To conclude the wine-tasting evening, we enjoyed a few Italian red wines at Weibel, and had a nice discussion with the Italian guy there. All in all a very nice event, which I'll be sure to go again next year.
After that we hooked up with a few other friends (albeit we were ~20 minutes late, sorry guys!) and went to eat Sushi at Nooch. I quite enjoy Asian food, and this was my first time eating Sushi, and I must say it was very good, but I still prefer all the fried Chinese food and stuff. ;)
After that we all went home, and me and Flavio watched another episode of "My name is Earl", it's a really hilarious show that I recommend to anyone. :D Yo, have a good day!

Posted by Luca Longinotti on 13 Nov 2009 at 10:54
Categories: Longi Comments



tmux

I'm finally back on the net, after not having any internet access at my new apartment in Zürich after I moved there. I now started my bachelor studies at the ETH Zürich, of course in Computer Science, though there's a little bit too much maths right now for me to be really excited about it, future semesters will be better I hope. So I'll try to get back to a few Gentoo things in the near future, now that I also finally fixed up my main dev system (which had its disk die just before I moved)... Still this blog entrys main focus is to tell you the name of a package I discovered today:

app-misc/tmux

After reinstalling this system I, as always before, emerged screen to take care of my detached terminal needs, I always had the problem with backspace not working correctly from the desktop, which I was never able to fix correctly, but it was bearable. This time it seems something else went wrong too, and inside my screen sessions it didn't source .bashrc or .bash_profile (which sources .bashrc), even if the shell was correctly set to a bash login shell...
So, while perusing Gentoo Wiki's Screen TIPs to see if anyone had seen something like this, at the end of that page I came across the mention of tmux, a "simple, modern, BSD-licensed alternative to GNU Screen".
Seeing that it only depends on ncurses (which is usually installed everywhere), and was only like 100kb of source, I installed it and tried it out. I have to say I'm impressed, this little tool does everything I did with screen too (mainly just having multiple, detached terminals and resuming them, which is probably no "advanced screen usage", but what most people will likely need), backspace works without any fiddling, the Bash stuff is correctly sourced, and the few commands are easy to adapt to, here a little overview:

  • tmux - Starts a new tmux session
  • CTRL-b d - Press CTRL-b, then d, to detach the terminal
  • tmux a - Reattach to the detached terminal

Still, read man tmux to get the full overview, and then happily emerge -C screen, as I just did.

Posted by Luca Longinotti on 05 Oct 2008 at 14:48
Categories: Longi, Gentoo, Software Comments



net-www/apache-1* masked

This I just wrote to gentoo-dev and gentoo-server, finally ending Apache-1* support in Gentoo.

Hi all!
As announced in the 30 April 2007 edition of GWN, net-www/apache-1* as well as all packages depending/using it were masked, pending removal on 12 June 2007.
I fixed all packages, dependencies, etc. I could find to work correctly after the masking (generally removing Apache 1.X support from them).
If you find any issue still, please open a bug about it, assign it to apache-bugs@gentoo.org and make it block bug 178189.
If you use or plan on using the apache-module or depend.apache eclasses, be aware that the need_apache function doesn't anymore export the apache2 USE flag to IUSE, since now it directly depends on Apache 2.X, so be sure to declare it in your ebuilds IUSE (I fixed the few cases where this wasn't already done).
Thanks and happy upgrading to Apache 2.X!

Posted by Luca Longinotti on 12 May 2007 at 15:44
Categories: Apache, Gentoo Comments




<< Previous Page -- Next Page >> (Page 6 of 10)