Re: ustring and multithread



Or the dll I use are not compiled for VS8 runtime like my program...

Ok, I understand what you say about mixing runtimes.

2008/6/17 Fabian Jacquet <fabian jacquet gmail com>:
:-) It's of course different strings. And I effectively use Windows :-D

Glib::ustring uses glib which is C library so It must share some context. Is it possible my binary of glib is not thread safe?


2008/6/17 Murray Cumming <murrayc murrayc com>:

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]