[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: iterators+multithreading on win32
From:       "Stephen F. Booth" <me () sbooth ! org>
Date:       2011-03-05 17:00:07
Message-ID: AANLkTinw3h8dGWjjpEJwT=xV6frwrbUW0iOKw+Yq9V-q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I've also run into crashes like this in the past, when I tried to realize
speed increases by parsing several files simultaneously in separate threads=
.
 It seems that if atomic increment/decrement were added to RefCounter, as
long as a single file wasn't shared across threads then STL thread safety
wouldn't be an issue.  I'm not sure which statics could affect this, as I
haven't looked through the code in a while.  Is thread safety (or some leve=
l
of it) something planned for a future release?

Stephen

2011/3/5 Luk=C3=A1=C5=A1 Lalinsk=C3=BD <lalinsky@gmail.com>

> On Sat, Mar 5, 2011 at 10:59 AM, =D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=
=B9 =D0=A8=D0=B0=D1=84=D0=BE=D1=80=D0=BE=D1=81=D1=82=D0=BE=D0=B2 <shafff@uk=
r.net>
> wrote:
> > Hi. We're getting crashes when using taglib from different threads
> (different files) on windows
> > all of them are in the crt functions called from std iterators (e.g.
> String's basic_string<ushort> iterator used in isLatin() methid, and also
> ByteVector's iterators).
> >
> > The hypothesis is that std iterators are not thread-safe on win32.
> >
> > What do you think if i convert the code to not use iterators (e.g.
> ifdefing the code)?
>
> The main problem is that TagLib uses non-thread-safe reference
> counting on shared objects. Until this is fixed, you should not use
> TagLib from multiple threads (yes, even on different files).
>
> I'm not aware of any code in TagLib that would use STL iterators
> across functions that could potentially get called from different
> threads, so I don't believe that's the problem.
>
> Lukas
> _______________________________________________
> taglib-devel mailing list
> taglib-devel@kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>

[Attachment #5 (text/html)]

I&#39;ve also run into crashes like this in the past, when I tried to realize speed increases by parsing \
several files simultaneously in separate threads.   It seems that if atomic increment/decrement were \
added to RefCounter, as long as a single file wasn&#39;t shared across threads then STL thread safety \
wouldn&#39;t be an issue.   I&#39;m not sure which statics could affect this, as I haven&#39;t looked \
through the code in a while.   Is thread safety (or some level of it) something planned for a future \
release?<div> <br></div><div>Stephen<br><br><div class="gmail_quote">2011/3/5 Lukáš Lalinský <span \
dir="ltr">&lt;<a href="mailto:lalinsky@gmail.com">lalinsky@gmail.com</a>&gt;</span><br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <div \
class="im">On Sat, Mar 5, 2011 at 10:59 AM, Николай Шафоростов &lt;<a \
href="mailto:shafff@ukr.net">shafff@ukr.net</a>&gt; wrote:<br> &gt; Hi. We&#39;re getting crashes when \
using taglib from different threads (different files) on windows<br> &gt; all of them are in the crt \
functions called from std iterators (e.g. String&#39;s basic_string&lt;ushort&gt; iterator used in \
isLatin() methid, and also ByteVector&#39;s iterators).<br> &gt;<br>
&gt; The hypothesis is that std iterators are not thread-safe on win32.<br>
&gt;<br>
&gt; What do you think if i convert the code to not use iterators (e.g. ifdefing the code)?<br>
<br>
</div>The main problem is that TagLib uses non-thread-safe reference<br>
counting on shared objects. Until this is fixed, you should not use<br>
TagLib from multiple threads (yes, even on different files).<br>
<br>
I&#39;m not aware of any code in TagLib that would use STL iterators<br>
across functions that could potentially get called from different<br>
threads, so I don&#39;t believe that&#39;s the problem.<br>
<br>
Lukas<br>
<div><div></div><div class="h5">_______________________________________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br> \
</div></div></blockquote></div><br></div>



_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic