Re: ustring and multithread



On Tue, 2008-06-17 at 15:24 +0200, Fabian Jacquet wrote:
> Hi all,
> 
> I don't know if it's the good mailing list for this question. Sorry if
> it's not.
> 
> I use libxml++ which depend on glibmm-2.4.dll on 2.12.7.1 version.
> libxml++ writes UTF8 so it use Glib::ustring.
> My program uses a lot of threads traiting xml and some time I have an
> "Access violation" error.
> It seams this error occurs on the operator== of the ustring...
> It's simply reproducible  with this code in threads:
> 
> Glib::ustring myString = "azerty";
> if(myString == "qsdfgh")
> ... 
> 
> I don't have any problem if I cast ustring in std::string before
> compare.
> Is there another solution?

Neither std::string or Glib::ustring are thread safe. You need to
protect access to them with a mutex if you are using the same strings
from multiple threads.

If you are not accessing the same strings from multiple threads then you
have some other problem. It sounds like you are using Windows, so maybe
you are mixing runtimes?

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]