# libxml2/threading/win 2003

- Thread: https://externals.io/message/25300
- Original archive: https://news-web.php.net/php.internals/25300
- Started by Rob Richards on 2006-08-10T21:02:34+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25300 — Rob Richards — 2006-08-10T21:02:34+00:00

URL: https://externals.io/message/25300#25300

In order to resolve reported crashing on win 2003, I have had to change 
the static libxml builds to use the flag LIBXML_STATIC_FOR_DLL.

This now requires a DllMain to be added within any dll that is building 
libxml2 in statically.
PHP 4.x - domxml (use php_domxml.c.diff.txt patch)
PHP 5.x/HEAD added within libxml.c (apply libxml.c.diff.txt to PHP 5 and 
HEAD - was made against HEAD)

This changes the threading a bit to work in the same manner as if 
libxml2 were built and linked to as a shared lib.

Along with these changes new libxml libraries are needed.
debug builds:
    http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
    http://ctindustries.net/libxml/libxslt-1.1.17.debug.php.zip

release builds:
    http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
    http://ctindustries.net/libxml/libxslt-1.1.17.php.zip

So far I have been testing these against 5.2 builds and ran a few tests 
with domxml in PHP 4.4 to make sure all was good. I would appreciate it 
if anyone running win builds make these changes to their local builds 
and let me know if anyone runs into any problems (there really shouldnt 
be any, but in any case..). Would like some additional outside testing 
before committing this stuff.

Rob

---

## #25303 — Edin Kadribasic — 2006-08-10T21:25:16+00:00

URL: https://externals.io/message/25300#25303 · In reply to: #25300

Hi Rob,

Since we're adding a DllMain function, shouldn't it be located in 
main/main.c. We might need to hook up other thread initialization stuff 
in there in the future.

Edin


Rob Richards wrote:
> In order to resolve reported crashing on win 2003, I have had to change 
> the static libxml builds to use the flag LIBXML_STATIC_FOR_DLL.
> 
> This now requires a DllMain to be added within any dll that is building 
> libxml2 in statically.
> PHP 4.x - domxml (use php_domxml.c.diff.txt patch)
> PHP 5.x/HEAD added within libxml.c (apply libxml.c.diff.txt to PHP 5 and 
> HEAD - was made against HEAD)
> 
> This changes the threading a bit to work in the same manner as if 
> libxml2 were built and linked to as a shared lib.
> 
> Along with these changes new libxml libraries are needed.
> debug builds:
>    http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
>    http://ctindustries.net/libxml/libxslt-1.1.17.debug.php.zip
> 
> release builds:
>    http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
>    http://ctindustries.net/libxml/libxslt-1.1.17.php.zip
> 
> So far I have been testing these against 5.2 builds and ran a few tests 
> with domxml in PHP 4.4 to make sure all was good. I would appreciate it 
> if anyone running win builds make these changes to their local builds 
> and let me know if anyone runs into any problems (there really shouldnt 
> be any, but in any case..). Would like some additional outside testing 
> before committing this stuff.
> 
> Rob
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: libxml.c
> ===================================================================
> RCS file: /repository/php-src/ext/libxml/libxml.c,v
> retrieving revision 1.51
> diff -u -r1.51 libxml.c
> --- libxml.c	6 Aug 2006 17:41:39 -0000	1.51
> +++ libxml.c	10 Aug 2006 20:25:31 -0000
> @@ -1043,6 +1043,13 @@
>  }
>  /* }}} */
>  
> +#ifdef PHP_WIN32
> +PHP_LIBXML_API BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
> +{
> +	return xmlDllMain(hinstDLL, fdwReason, lpvReserved);
> +}
> +#endif
> +
>  #endif
>  
>  /*
> 
> 
> ------------------------------------------------------------------------
> 
> Index: php_domxml.c
> ===================================================================
> RCS file: /repository/php-src/ext/domxml/Attic/php_domxml.c,v
> retrieving revision 1.218.2.50.2.2
> diff -u -r1.218.2.50.2.2 php_domxml.c
> --- php_domxml.c	18 Mar 2006 10:46:27 -0000	1.218.2.50.2.2
> +++ php_domxml.c	8 Aug 2006 11:47:17 -0000
> @@ -5520,6 +5520,13 @@
>  /* }}} */
>  #endif /* HAVE_DOMXSLT */
>  
> +#ifdef PHP_WIN32
> +__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
> +{
> +	return xmlDllMain(hinstDLL, fdwReason, lpvReserved);
> +}
> +#endif
> +
>  #endif /* HAVE_DOMXML */
>  
>  /*

---

## #25305 — Rob Richards — 2006-08-11T01:52:28+00:00

URL: https://externals.io/message/25300#25305 · In reply to: #25303

Doesn't really matter where it is. The only reason I added it in 
libxml.c was since libxml2 was the first/only lib needing a DllMain in 
teh php5ts_xxx.dll build, I put it there so there was minimal changes to 
the core code.
Evenutally I thought it might make more sense to me moved elsewhere so 
other extensions could (if needed) take advantage of it.

Rob

Edin Kadribasic wrote:
> Hi Rob,
>
> Since we're adding a DllMain function, shouldn't it be located in 
> main/main.c. We might need to hook up other thread initialization 
> stuff in there in the future.
>
> Edin

---

## #25399 — Rob Richards — 2006-08-22T00:02:14+00:00

URL: https://externals.io/message/25300#25399 · In reply to: #25303

Now that 5.1.5 and 4.4.4 have been released, is it possible to get these 
changes and updated lib in?
Ilia, not sure if this interrupts your RC schedule at all, but this 
change should resolve many of the windows crashes reported under 2003, 
so would like to get this into 5.2.

Rob

Edin Kadribasic wrote:
> Hi Rob,
>
> Since we're adding a DllMain function, shouldn't it be located in 
> main/main.c. We might need to hook up other thread initialization 
> stuff in there in the future.
>
> Edin
>
>
> Rob Richards wrote:
> > […]

---

## #25421 — Andi Gutmans — 2006-08-25T02:48:24+00:00

URL: https://externals.io/message/25300#25421 · In reply to: #25300

Rob,

Is there a reason why we can't call this from MINIT? I'm not sure a good
long-term solution is to have a DllMain when we don't need one.

Andi 

> -----Original Message-----
> From: Rob Richards [mailto:rrichards@ctindustries.net] 
> Sent: Thursday, August 10, 2006 2:03 PM
> To: Edin Kadribasic; internals@lists.php.net
> Subject: [PHP-DEV] libxml2/threading/win 2003
> 
> In order to resolve reported crashing on win 2003, I have had 
> to change the static libxml builds to use the flag 
> LIBXML_STATIC_FOR_DLL.
> 
> This now requires a DllMain to be added within any dll that 
> is building
> libxml2 in statically.
> PHP 4.x - domxml (use php_domxml.c.diff.txt patch) PHP 
> 5.x/HEAD added within libxml.c (apply libxml.c.diff.txt to 
> PHP 5 and HEAD - was made against HEAD)
> 
> This changes the threading a bit to work in the same manner as if
> libxml2 were built and linked to as a shared lib.
> 
> Along with these changes new libxml libraries are needed.
> debug builds:
>     http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
>     http://ctindustries.net/libxml/libxslt-1.1.17.debug.php.zip
> 
> release builds:
>     http://ctindustries.net/libxml/libxml2-2.6.26.threads.zip
>     http://ctindustries.net/libxml/libxslt-1.1.17.php.zip
> 
> So far I have been testing these against 5.2 builds and ran a 
> few tests with domxml in PHP 4.4 to make sure all was good. I 
> would appreciate it if anyone running win builds make these 
> changes to their local builds and let me know if anyone runs 
> into any problems (there really shouldnt be any, but in any 
> case..). Would like some additional outside testing before 
> committing this stuff.
> 
> Rob
