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

Re: [xml] Crash pb with multi-thread program (libxml2.7.1, Win32, msvc v15.00.21022.08)



On Thu, Sep 11, 2008 at 4:48 PM, Philippe BOINOT
<philippe boinot pertimm com> wrote:
> Hello,
>
> On Windows XP, I have a crash when some functions in libxml2 are in
> interaction with threads.

Please read the documentation about Thread Safety:
http://xmlsoft.org/threads.html

Specifically, it doesn't look like you're doing #2:
" - call xmlInitParser() in the "main" thread before using any of the
libxml2 API (except possibly selecting a different memory allocator)"

Hope that helps,

Boz

>
> #include <stdio.h>
> #include <errno.h>
> #include <windows.h>
> #include <winbase.h>
> #include <process.h>
> #include <libxml/tree.h>
>
> int threadfunc(void *arg) {
>  xmlBufferPtr crashTest=NULL;
>  fprintf(stderr,"Crash test in thread\n");
>  crashTest=xmlBufferCreate(); // <------------ !!!  Crash, access
> violation !!!
>  fprintf(stderr,"alive?\n");
> }
>
> int main(int argc, char **argv)  {
>  int rc;
>  xmlBufferPtr crashTest=NULL;
>
>  fprintf(stderr,"Starting thread crash with libxml?\n");
>  crashTest=xmlBufferCreate();
>  fprintf(stderr,"no crash in main thread\n");
>  if ((rc = _beginthread(threadfunc, 0,NULL))==-1) {
>    fprintf(stderr,"Thread creation error\n");
>    exit(1);
>  }
>  while (1==1) ;
> }
>
>
> The stack is here :
> -------------------
>
> 'test.exe': Loaded
> 'D:\Philippe\Atelier\pertimm\ogmios\build\debug\bin\test.exe', Symbols
> loaded.
> 'test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
> 'test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
> 'test.exe': Loaded
> 'D:\Philippe\Atelier\pertimm\ogmios\build\debug\bin\libxml2.dll',
> Symbols loaded.
> First-chance exception at 0x7c928fea in test.exe: 0xC0000005: Access
> violation writing location 0x00000010.
> Unhandled exception at 0x7c928fea in test.exe: 0xC0000005: Access
> violation writing location 0x00000010.
> The program '[2864] test.exe: Native' has exited with code 0 (0x0).
>
>
> The crash occurs in code libxml2/threads.c :
> --------------------------------------------
> if (cleanup_helpers_head !=NULL) {
>    cleanup_helpers_head->prev=p;
> }
>
> ---
>
> I'm using a self compiled libxml2.7.1, with this option : cscript
> configure.js iconv=no
> -------------------------------------------------------------------------------------
>
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.
> libxml2 version: 2.7.1
> Created Makefile.
> Created config.h.
> XML processor configuration
> ---------------------------
> Trio: no
> Thread safety: native
> FTP client: yes
> HTTP client: yes
> HTML processor: yes
> C14N support: yes
> Catalog support: yes
> DocBook support: yes
> XPath support: yes
> XPointer support: yes
> XInclude support: yes
> iconv support: no
> iso8859x support: no
> zlib support: no
> Debugging module: yes
> Memory debugging: no
> Runtime debugging: no
> Regexp support: yes
> Module support: yes
> Tree support: yes
> Reader support: yes
> Writer support: yes
> Walker support: yes
> Pattern support: yes
> Push support: yes
> Validation support: yes
> SAX1 support: yes
> Legacy support: yes
> Output support: yes
> XML Schema support: yes
> Schematron support: yes
> Python bindings: no
>
> Win32 build configuration
> -------------------------
> Compiler: msvc
> C-Runtime option: /MD
> Embed Manifest: no
> Debug symbols: no
> Static xmllint: no
> Install prefix: .
> Put tools in: $(PREFIX)\bin
> Put headers in: $(PREFIX)\include
> Put static libs in: $(PREFIX)\lib
> Put shared libs in: $(PREFIX)\lib
> Include path: .
> Lib path: .
>
> ------------------------------------------
>
> Compiler : Microsoft (R) 32-bit C/C++ Optimizing Compiler Version
> 15.00.21022.08 for 80x86
>
> Crash programm is compiled with options : /W3 /O2 /MD
>
> Regards
>
> Philippe
>
>
> _______________________________________________
> xml mailing list, project page  http://xmlsoft.org/
> xml gnome org
> http://mail.gnome.org/mailman/listinfo/xml
>


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