[xml] If LibXML2 is compiled with pthreads support on Windows it causes a crash.



I am using MinGW with GCC 4.5.2 on Windows 7 x64 compiling 32-bit
programs. I have compiled libxml2 from source. I had used the
configure.js script in the win32 folder, I was able to produce a
static version only.
Ever since, I used that one, but my binary size was over a megabyte
big(otherwise it worked perfectly), because of the static version of
libxml2. So since with configure.js I had no option to make a shared
library of libxml2 I resorted to using the standard ./configure script
which is in the main path.

Everything went smoothly, I produced a static AND shared version, but
thread support was auto set to pthreads. I linked to libxml2.dll.a, as
soon as I ran the program I immediately got a crash in
libpthread-2.dll. Same thing with the static version produced by
standard ./configure. Using GDB I was able to track the problem to
threads.c around line 658
which is this code

xmlGlobalStatePtr
xmlGetGlobalState(void)
{
#ifdef HAVE_PTHREAD_H
    xmlGlobalState *globalval;

    if (libxml_is_threaded == 0)
        return (NULL);

    pthread_once(&once_control, xmlOnceInit);

    if ((globalval = (xmlGlobalState *)
         pthread_getspecific(globalkey)) == NULL) {
        xmlGlobalState *tsd = xmlNewGlobalState();
        if (tsd == NULL)
            return(NULL);

        pthread_setspecific(globalkey, tsd);
        return (tsd);
    }
    return (globalval);

More specifically,  pthread_setspecific(globalkey, tsd); is where the
crash occurs. Using the one compiled with configure.js in the win32
folder(and makefile.mingw) I see the option to use threads was set to
native, I have no problem with that library but there is only a static
library available. However if I specify threads=pthreads in
configure.js and produce a library, it also causes a crash. Anything
related to pthreads IN libxml2 causes a crash. But my application also
uses pthreads to spawn threads.

Any possible fix for this?



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