threadsafety? #155

Closed
opened 2026-01-29 20:38:56 +00:00 by claunia · 2 comments
Owner

Originally created by @marcuskbr on GitHub (Feb 2, 2017).

Recently I get SEGV signals inside the brotli directory decoding content of Youtube and I was wondering if this brotli library is threadsafe ?
I.e. can I use multiple threads that repeatedly do this:

bstate = BrotliDecoderCreateInstance( NULL, NULL, NULL );
bretval = BrotliDecoderDecompress( ... );
BrotliDecoderDestroyInstance( bstate );
Originally created by @marcuskbr on GitHub (Feb 2, 2017). Recently I get SEGV signals inside the brotli directory decoding content of Youtube and I was wondering if this brotli library is threadsafe ? I.e. can I use multiple threads that repeatedly do this: ``` bstate = BrotliDecoderCreateInstance( NULL, NULL, NULL ); bretval = BrotliDecoderDecompress( ... ); BrotliDecoderDestroyInstance( bstate ); ```
Author
Owner

@eustas commented on GitHub (Feb 6, 2017):

Brotli does not use any shared mutable data; but there are no explicit memory barriers.

So, as long as all things with a single instance are done within one thread - it is safe; every thread may work with as many instances as it wants.

But as soon as instance is passed between threads, developer should take care of exclusive access to the instance and appropriate memory barriers.

@eustas commented on GitHub (Feb 6, 2017): Brotli does not use any shared mutable data; but there are no explicit memory barriers. So, as long as all things with a single instance are done within one thread - it is safe; every thread may work with as many instances as it wants. But as soon as instance is passed between threads, developer should take care of exclusive access to the instance and appropriate memory barriers.
Author
Owner

@eustas commented on GitHub (Feb 6, 2017):

I believe this model is called "conditionally safe".

@eustas commented on GitHub (Feb 6, 2017): I believe this model is called "[conditionally safe](https://en.wikipedia.org/wiki/Thread_safety)".
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#155