19 Feb 2004 thomasvs   » (Master)

Suit

Forgot to mention that last weekend Kristien and I went shopping for a suit for me. I guess I forgot it because I mentally blocked out all memory of it. I just DON'T like to go shopping when everyone is doing the same thing and every store is filled to the brim with people. I especially don't like to go shopping when it's to buy stuff I don't feel I need. Because I like the suit I have already, but Kristien doesn't.

Anyway, so we found a suit but had a bad time finding it, and I didn't feel like explaining a lot to her what was wrong, so I hid behind Standard Guy Excuse #593059: "We just don't like shopping for clothes. We do not have breasts."

Well, that's a bit of a lie. I love to go shopping when everyone else is working, when I have the place to myself, can try out stupid stuff, and act like a kid in the booth while annoying my companion on purpose by embarassing them to hell. All of this cannot be done when there are lots of people around.

It didn't help when I wanted to go look at watches to replace my broken watch, and she tried to get me away from them. After two minutes she broke down saying she got me a watch for our one-year-togetherness. She always complains I'm too good at guessing what present I'm getting, and this time she forbade me to even try to guess. And now I managed to guess it without even trying, and it made her cry.

So baby, I should take you out for a rematch soon and do some real shopping.

City

Sometimes Barcelona weirds me out, in a good way. Yesterday there was some sort of taxi strike - a huge colonne of taxis was blocking the major streets close to work, tooting their horns. Nobody knew why.

I looked on the net for tango places - apparently I could go out and tango EVERY NIGHT. I have to get started soon.

GStreamer

Started throwing random files at GStreamer and the player to test for robustness. File number two was a tar.gz. It triggered an endless loop. After some debugging, it seems the typefinding functions serve up the file to gdk_pixbuf, who passes it on to the librsvg pixbuf loader, which tries to see if there's an svg inside it. Then when it tries to close it, for some reason it triggers an infinite loop. Not knowing anything about librsvg, I dug in and managed to find and fix the loop quickly. It taught me again I should always check for error codes on functions.

Anyway, made me think about the general problem - if GStreamer uses 50 libs, should we really trust all these libs not to have a simple mistake in them that makes all of GStreamer lock up so easily ? So I decided I wanted to set timeouts on lib function calls when we know they cause a problem.

After a day of experimenting, it seems this is possible, but a bit convoluted. Basically, the best/most portable way to do this is

  • start an alarm thread that listens to ALRM, or any other timer signal

  • block delivery of ALRM to the main thread

  • alarm thread should send USR1 to the current process when catching an ALRM

  • before calling a function, set a USR1 handler (which will run in this thread), store the setjmp point in a global per-thread hash, and set alarm

  • if the next function call doesn't return in the given time, ALRM is raised and delivered to the process. Since the alarm thread is the only one listening to ALRM, it will be the only one receiving it. It will then raise USR1, and since the actual thread that is calling the function is the only one listening to it, it will receive the notification correctly as well. So the USR1 callback can then longjmp back to before the blocking function, and it can thus be skipped

Fairly convoluted. Drawbacks ? Right this doesn't allow more than one thread at the same time to use this timeout mechanism (which could probably be fixed by keeping track of alarm times and setting them, so that each thread catching an alarm can check if it's meant for that thread, and reraise if needed). Also, people might complain they cannot use ALRM for their own program anymore (though we can make the whole timeout optional too, which I'll probably do). And, some people may feel this is a hack.

Well, it's not actually a hack, it's the right way to do this. Only it is so low-level that people automatically consider it a hack. I, on the other hand, feel we really should do this if we want to make sure GStreamer answers to user expectations in general. Which means, it just shouldn't lock up when trying to play a random file.

FOSDEM

Leaving tomorrow morning, yay ! Hope to arrange some paper matters too while I'm in Belgium, and visit some friends. Now playing

Six by Seven - eat junk become junk. How this amazing disc got so widely ignored is really beyond me.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!