2006.09.22 14:20 "[Tiff] libjpeg", by Philip Watkinson

2006.09.22 16:31 "Re: [Tiff] libjpeg", by Bob Friesenhahn

Is libjpeg thread safe?

An often debated question, but in my opinion `no'. The only safe way to use it is under a lock.

Are you claiming a lock is necessary for serializing all LibJpeg usage, or a lock is necessary per decoding/encoding session? In either of these cases, what exactly do you think is the unsafe stuff?

The problem is with the dependence on setjmp/longjmp for error recovery. These APIs were never designed with multi-thread in mind and are not thread safe on many (most?) platforms. Unless specifically documented to be thread safe, one must assume not thread safe for these APIs. Other than this, I think that libjpeg is pretty thread safe. Libpng has the same problem as libjpeg.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/