[CELT-dev] Encoder crash in multithreading processing

Jean-Marc Valin Jean-Marc.Valin at USherbrooke.ca
Wed May 20 09:00:59 PDT 2009

Quoting Serguei Kouratov <ksubox at gmail.com>:

> Hi, I try to work with CELT encoder & decoder in 2 different threads at the
> same time.
> So I create/destroy encoder and encode in one thread and create/destroy
> decoder and decode in other thread.
> If I didn't protect celt_encoder_create, celt_encode_float and
> celt_decoder_create, celt_decode_float with CRITICAL_SECTION
> I get stable error in icwrs32 or ec_byte_write1 (more often) in encoder.
> What does it mean ? Is CELT not thread-safe ? Any way to avoid this error

CELT is designed to be thread-safe in the context you're describing. While
there's a (tiny) chance that we have inadvertently defined a global variable,
it's much more likely that there's a race in your code that causes CELT to be
corrupted. That being said, if you manage to find any case where we really
aren't thread-safe, then we'd like to fix that. Also, just in case there's
something wrong in the mode, can you try creating two mode objects (one the
encoder and one for the decoder) instead of one? It should work with one, this
is just to check that there's nothing wrong with the way the modes are being
shared by the encoder and decoder.



More information about the celt-dev mailing list