Archive for January, 2005

Use lynx, go to jail

Friday, January 28th, 2005

Ho ho ho. Courtesy of Boing Boing:

Jailed for using a non-standard browser.

Silly BT personage :-)

libxml2 thread safety

Thursday, January 20th, 2005

After an episode today in work with stability testing, where my code turned out not to be very stable, I think it’s time that I start thinking about putting up a page with details of how to efficiently perform multithreading with libxml2 and libxslt.

Things like (this is what bit me today) mutex-locking the creation and destruction of XSLT parser and stylesheet contexts - as they share dictionaries, and the reference counting for the dictionaries isn’t thread-safe.
I don’t know if this page will actually happen, but I’m sure I’ll come across a few more gotchas before I’m finished with this project!

The kind of backtrace I got was:

#0 0×400c2b41 in __kill () from /lib/i686/libc.so.6
#1 0×4004987b in raise (sig=6) at signals.c:65
#2 0×400c40c2 in abort () at ../sysdeps/generic/abort.c:88
#3 0×0822ddae in xxxxx (ptr=0×876cfd8, f=0×82c6479 “xxxxx.c”, l=646) at xxxxx.c:xxx
#4 0×080b36ef in free_func (mem=0×876cfd8) at xxxxx.c:xxx
#5 0×081b9ded in xmlDictFree (dict=0×8762ec0) at dict.c:472
#6 0×08192a0c in xmlFreeDoc (cur=0×8766158) at tree.c:1157
#7 0×081c9bf5 in xsltFreeStylesheet (sheet=0×8766268) at xslt.c:495

That was caused by an abort() upon detection of a double-free. The crash was also seen under xmlXPathFreeCompExpr(), also when freeing the dictionary.

*Mini-Update:* I decided to send a patch to the libxml2 mailing list instead. It’s quite likely to be more efficient (more granular locking). And the acceptance of patches like this means that a page on how to do multithreading with libxml2 is a bit less important.

I think actually that it was only with 2.6.7 or thereabouts that libxml2 seriously began to take care of internal race conditions in certain shared areas (like the catalog).

Christmas Period

Friday, January 7th, 2005

The post-Christmas period was spent skiing with my family in Sauze d’Oulx. Usually ski trips involve complete removal from the world at large - not a word about the world outside is heard until the return home. Not this time. The tsunami event unfolded throughout the trip, as the scale of the disaster became horribly apparent. There is little I can say about that currently, as it beggars my imagination to think of the suffering that happened, and that which is ongoing in those countries right now.

Besides that, there was food, there was skiing, I got flu for the last day or two of the trip. And now it’s back to work.