|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15333 strndup access violation
Submitted: 2002-02-01 15:41 UTC Modified: 2002-12-27 14:24 UTC
Avg. Score:4.8 ± 0.5
Reproduced:72 of 72 (100.0%)
Same Version:47 (65.3%)
Same OS:56 (77.8%)
From: david at harksystems dot com Assigned:
Status: Closed Package: IIS related
PHP Version: 4.3.0-dev OS: Windows 2000 Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
50 + 46 = ?
Subscribe to this entry?

 [2002-02-01 15:41 UTC] david at harksystems dot com
I am getting an access violation in php4ts!zend_strndup + 0x2B + 0xA05CB1AD.

It is reproducable after about 20 or 30 requests, but it isn't a certain page that causes it.  A page refresh may or may not display the page without error.  Eventually the server will no longer serve pages at all and only a reboot will bring the web server back.  Stopping IIS just sits there attempting to stop the service.

Windows 2000 Pro with service pack 2 and all critical and security updates from
K6-2 500MHz with 192Meg RAM

I have the exact setup on my machine using an Athlon 1.2GHz with 512Meg RAM without any problem.  However on two machines with an AMD K6-2 (configured identically) the web server will stop responding to requests consistently.  I have also tested this on my Dell laptop with an Intel PIII/700MHz 256 Meg RAM with same Windows 2000 pro w/sp2 and all updates without any problem.

When the server does stop serving pages the DLLHOST.EXE process virtual memory size goes to the max for the machine.

I have installed php as an ISAPI module.  I have also tried installing PHP as a CGI and have the same problem.

I have tested this with php 4.0.6, 4.1.0, and 4.1.1 and have the same problem in zend_strndup with all three.  I am using the windows zip file from the download page.  Also I am using the Interbase extension.  No other extensions are being used.

I hope I included enough info here.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-19 08:52 UTC] pthiebaud at labeltechnologies dot com
Are you using Zendencoder? I have the same problem on a machine running Zendoptimizer with some pages that were Zendencoded. The server crashed every 20-30 request or so. I took off the pages Zendencoded and its working fine now... Seems that the problem stands there...
 [2002-02-19 09:06 UTC] david at harksystems dot com
Nope, I am not using Zend Encoder or Optimizer.  Just running plain PHP for now.
 [2002-04-03 19:35 UTC] agustinchernitsky at hotmail dot com
I got this error after aplying the lateste security updates on my win2k server. It works fine at the begginig but after 5 mins I get this error. It hangs all the IIS service. 

This doesn't happen in CGI mode.

OS: Win2K Server
Patches: SP2 + Lateste Security updates
System: P3 @ 550 Mhz - 256 MB RAM
PHP VER: 4.1.2.
 [2002-04-04 10:09 UTC]
Bug #16362 was marked a duplicate of this bug.
 [2002-04-04 10:27 UTC] develop at dnet dot net
I've been having the same problem.

Win2k (All security updates)
IIS 5.0
Pentium III 733
ISAPI Version 4.1.2

I switched security on each virtual directory to 'Low(IIS Process) and haven't gotten the error since.  This isn't a satisfactory fix, but maybe it'll help figure out what is causing the problem.
 [2002-04-04 13:23 UTC]
I think I've found the problem:

ZEND_API char *zend_strndup(const char *s, uint length)
	char *p;

	p = (char *) malloc(length+1);
	if (!p) {
		return (char *)NULL;
	if (length) {
		memcpy(p, s, length);
	p[length] = 0;
	return p;

If this is changed to 

ZEND_API char *zend_strndup(const char *s, uint length)
	char *p;

	p = (char *) malloc(length+1);
	if (!p) {
		return (char *)NULL;
	if (length) {
		memcpy(p, s, length);
		p[length] = 0;
	return p;

does that break anything?  I think the problem comes in when length==0.  I can't really reproduce this problem though.  I saw it once a couple of days ago, but havn't seen it since.

Also will one of you that's having this problem please check to see if 4.2.0 RC 2 still has this problem?  Since 4.2.0 is going to be released really soon now, I'd like to get this worked through (but if it doesn't happen anymore under 4.2.0 then we're worrying about nothing).
 [2002-04-05 12:38 UTC]
Nevermind.  That's not the problem.  Still looking.
 [2002-04-08 12:04 UTC]
Ok.  It definitely happens with RC2.  You can restart IIS without rebooting, you've got to perform the following:

kill the inetinfo.exe process using the task manager
run from command line:
net stop w3svc
net stop iisadmin
net start iisadmin
net start w3svc

Marking this bug critical because it should be fixed before 4.2.0 release.  Still looking for fix.
 [2002-04-09 08:14 UTC] develop at dnet dot net
I have been super busy lately, but, since I switched the app protection down to 'Low (IIS Process)' a week ago I haven't gotten a single error or lock up.  Thanks for your persistance.

Still using 4.1.2.
 [2002-04-17 01:29 UTC] jim dot borowicz at amivisions dot com
I am also receiving this error with:
Win2k Server SP2 w/all security patches
But I am running PHP 4.1.2 ISAPI under IIS 5.0

 [2002-04-17 15:19 UTC] marcus dot b dot brock at lmco dot com
I am getting this error with 4.2.0 RC2.  I upgraded from 4.1.2 to 4.2.0 RC2 (both ISAPI) because 4.1.2 wasn't handling sessions correctly. 

I tried setting the app protection to 'Low (IIS Process)' and all I received were 'Invalid access to memory location' errors. 

PHP 4.2.0 RC2 (ISAPI)
Win2K Pro SP2  
384 MB RAM
 [2002-04-21 06:32 UTC] llowry at novell dot com
I tried setting the app protection to 'Low (IIS Process)' and still get the error.  And I tried killing inetinfo.exe and running the net stop commands from the command line, but Windows won't kill the process.

This issue has turned out to be the biggest reason my I haven't embraced PHP yet -- because I hate rebooting my machine all of the time.  

I would love to hear of a workaround that works, and better yet, see a published fix.  Any more ideas out there?
 [2002-04-22 19:26 UTC] mail-php dot net at kimihia dot org dot nz
There is a tool called "tkill" / kill / tlist that will let you terminate processes. Get the PID from tlist or Task Manager and then run kill with the PID for the argument.

inetinfo.exe will be running under a different user that Administrator does not have the power to kill the processes of, so using Task Manager to kill inetinfo.exe is a waste of time.
 [2002-04-23 18:35 UTC] develop at dnet dot net
how do I go about running 'tkill'?
 [2002-05-10 04:22 UTC] stefan at digiconcept dot net
I've got the same configuration (win2k, iis5 and mssql via obdc) the machine want to run propperly and i've seen the same errors. now, php is configured in the applications mappings AND in the isapi filters (seen here somewhere as a hint). the site is "stored" in a fully configured virtual host ( assign ip-address, assigned host name, cache scripts etc etc). now, it runs stable without any of the strange errors described in the other postings. dont ask me why, i'm not really happy but so far it's a prove that the "mission impossible became reality" ;-) and it had cost me some hard days to make it true.

btw: no zend encode or optimizer is installed
 [2002-05-14 17:08 UTC] mdavis at cbsh dot com
Any update to this?  Using PHP 2.0 Gold and still haveing this problm:

php4ts!zend_strndup + 0x2B
 [2002-05-14 17:46 UTC]
Uh, PHP 2.0 Gold?  What the heck is that?
 [2002-05-15 10:23 UTC] mdavis at cbsh dot com
I beleive that is what it was being called when I downloaded it, maybe I am mistaken.

Anyway I am now running php 4.2.1 and am having the same problem.

Windows 2000 Server
Stock PHP 4.2.1 install
Stock MySQL 3.29 install
Stock phpBB 2.0 install
The HTTP server encountered an unhandled exception while processing the ISAPI Application '
php4ts!zend_strndup + 0x2B
 + 0xA05E5983
 [2002-05-17 13:37 UTC] agustinchernitsky at hotmail dot com
Running PHP 4.2.1
Win2K Server with all Security Updates

Still getting the ISAPI module error. My event Log shows:

Event Type:	Warning
Event Source:	W3SVC
Event Category:	None
Event ID:	36
Date:		17/05/2002
Time:		14:09:30
User:		N/A
Computer:	SERVER2
The server failed to load application '/LM/W3SVC/24/Root/admin'.  The error was 'The application called an interface that was marshalled for a different thread.
For additional information specific to this message please visit the Microsoft Online Support site located at: 

Where /Root/admin is the virtual dir running PHP files.
 [2002-06-03 09:40 UTC]
Update version.
 [2002-07-06 07:24 UTC] nagender at sancharnet dot in
I am using latest Download from i.e php 4.2.1 with IIS 5 on Win2k Server running as ISAPI and always get the ACCESS VIOLATION ERROR after 10-15 pages and then every single page. Even when i restart IIS , the problem doesn't go away. On rebooting, the events cycle again. 
Gone thru all the messages, seems like nobody has much clue as to why newer versions of php are giving this error and strange fact is that php developers aren't paying any attention :(
 [2002-07-06 07:46 UTC]
Reproduced here.

Paying attention is relative. The number of developers under win32 is far less then the number of unix developers, simply.
 [2002-07-08 11:45 UTC]
I looked for the solution to this bug for more time than I had to spend.  Problem A is that debugging under IIS is more than a little bit of a hassle.  Problem B is that it seems to be a bogus pointer or corrupted memory that causes the access violation, and I wasn't able to track it down.  

Patches that fix the problem are very welcome, in the mean time, changing the security model to "low" seems to be a valid workaround.
 [2002-07-15 09:50 UTC] agustinchernitsky at hotmail dot com
Okey, this is an update... Interesting one.

Since I really need PHP running in ISAPI (for cookies, performance, etc), I reinstalled this weekend our main development server.

I installed the server with Windows 2000 Server and applied Service Pack 2. Before we updated the server with the latests security patches from MS, my server was running SP2 and PHP 4.1.2 with no problems. After the Security Patches, everything went wrong.

Now, what happened with a Win2k clean installation, with SP2 and PHP 4.2.1: It didn?t work. Got the same PHP Isapi error as before.

Hope it helps.
 [2002-07-15 19:12 UTC] david dot vidmar at email dot si
Did you (developers) try to contact MS? I'm sure they would be of some help with this bug!
 [2002-07-16 22:26 UTC] akierum at yahoo dot com
To restart IIS try to use "Restart IIS" rather than doind stop start. Worked for me :)
 [2002-07-22 16:07 UTC]
Although there seems to be a common failure in strndup this is probably due to a buffer overflow somewhere which is being caused to overflow by strndup, I can never get these IIS bugs to repeat on my system, IIS seems about as stable as possible here, could you all give me your EXACT versions of 2k, IIS etc and Ill do my best to look into it, if not please can someone install MS VC6 and debug the process when it crashes (See technet/msdn on howto debug services) and get a stack trace so we can see where this crash is happening. I dont really think this bug is critical as things have never been that great on IIS and although its a hassle for a lot of people a work around would be to use PHP as CGI. Removing Critical status.

- James

 [2002-07-23 10:45 UTC] tshazli at linuxmail dot org
To James;
I have installed 3 machines with IIS 5 on win2k. They all have the same problem with the access violation If you are using PHP ISAPI AND you are accessing a database. On my m/c, I am accessing MSSQL server using ADODB. I've tried using ODBC or MSSQL server ext. module. They fail much more often than using the ADODB. Your system might be stable because maybe you do not use DB or the load on your system is very low. I also noticed that this happens when more than one process are trying to access the DB at the same time (Might help!).

Also if you use the low protection in IIS, It helps but does not prevent the problem (the access violation happens less often).

Also, to kill the IIS, you need to do the following; There is a file called (iisreset.exe). Dunno why MS made that file (probably a bug they know about it in IIS and cannot fix it) but this file is executed whenever you try to kill IIS. It is a bug itself. So delete this file from the system folder and from DLLCache folder. But you have to know if you delete this file, and IIS craches, you have to restart IIS manually (Or install some monitoring software that monitors the service and restart it whenever it goes down).

Also I noticed that adding the ISAPI to each virtual site filter (not from the properties of the IIS itself but rather from each Virtual website properties) helps reducing the AV.
 [2002-07-23 18:26 UTC] ken at rockies dot ca
Also getting this bug with PHP 4.2.2
 [2002-07-26 14:10 UTC] agustinchernitsky at hotmail dot com


IIS 5.0.2195.2966

PHP 4.2.1

Create a Web Site with ISAPI, make the PHP do some lookups in MySQL (Install PHPMyAdmin). That should do it... No security Service Packs are Installed, Just SP2.
 [2002-08-14 13:41 UTC] tgannon at colliers-seeley dot com
    I can't come up with a working test case but I have an idea which might help narrow the search.  I have two PHP applications, one of which works fine in IIS and the other of which causes this bug frequently.  The only significant difference that I can find between the two apps is that the one that hangs IIS uses sessions and cookies, whereas the stable one does not.
    I removed the calls to session_start and session_register from the unstable one, and after some testing it appears to still work.  I'll give an update after some more testing has been done.

Windows 2000 Server, Service pack 3 + .NET Framework (sp2)
PHP 4.2.2 as ISAPI
 [2002-08-20 20:15 UTC] stan dot noSPAM_ at noSPAM_ dot daft dot cc
Win2k Server, latest security patches
IIS 5.0
Connections to both mySQL, MSSQL.
Cookie and session usage.

The error of which I was receiving after about 15 page views:
"PHP has encountered an Access Violation at 011929AE"
was solved by...

1. updating all DLLs by copying DLLs included with PHP into C:\winnt\system32
2. having php4isapi.dll in both my ISAPI Filters and Home Directory > Configuration (under the Site properties)
3. setting Application Protection to Low (IIS Process)
4. restarting the server

After doing the above, I haven't seen the error since.
 [2002-08-29 08:30 UTC] jean-francois_larvoire at hp dot com

I have the same problem too. And it is reproductible.
This is with the ISAPI version of PHP 4.2.2 under Windows XP.
I get the following error message in the XP Error Log, when trying to access a page from another PC.
A copy of the test file that causes the problem is at
Pressing on the "Next month" button crashes the PHP DLL.

Jean-Francois Larvoire

The HTTP server encountered an unhandled exception while processing the ISAPI Application '
php4ts!zend_strndup + 0x2B
 + 0x17C99F70
For additional information specific to this message please visit the Microsoft Online Support site located at:

For more information, see Help and Support Center at
 [2002-09-05 00:14 UTC] home at NOSPAMwebpanache dot com

Just to contribute had PHP with ISAPI dll working fine until a few days ago.
It seems that applying the lastest Microsoft security fixes created the problem. The latest applied fix was MS02-048....
 [2002-09-06 21:08 UTC] tshazli at linuxmail dot org
Ok, here is the thing:
I have 2 servers load balancing each other. had this problem with one of our servers (PIII dual processor) but not with the other which is a single processor. I tried to format the server, reinstall everything all over again, not apply microsoft patches/fixes...etc. still the problem occurs ONLY on the dual processor server. Then I tried to take one processor out of that box and guess what...IT worked flawlessly. I stress tested it with heavy load test for hours and not once I got the error ever again. I put the processor back to the box and tested it. I got the error again. I tried that many times. Always get the error with dual processor but not even once with single processor.

So how to work around the problem? use single processor server. 
What causes the problem? dont know..It is between PHP and IIS. I am trying to find out the problem by debuging the services but if anyone is interested in reproducing the problem and trying to debug it, use dual processor with win2000 server and IIS5 with any php ver >=4.2.1 and use ADODB or MSSQL connections. Stress test it and you will get the error.
 [2002-09-07 00:04 UTC]
Please try using this CVS snapshot:
For Windows:

There was a bug for dual processors that fixed this.  Please try the latests version (4.2.3) to see if this is fixed.
 [2002-09-07 00:09 UTC]
Umm that should only be feedbacked, not closed.
 [2002-09-20 10:41 UTC] j dot mak at 1000mbit dot nl
Just to add it to the list:

Same problem here. Never got PHP to work through IIS.
Tested it on Win2K Pro (SP2, no patches), Win2K Adv. Server (sp2 + srp1), Win2K Adv. Server (SP3 + latest patches).

The machines vary from Duron cpu's, Celeron's, P3's, Athlon XP+'s.

A request to a .php file would work for 1 or 2 times, but then the 'Invalid access to memory location' error in my browser. The php files tried where some files with only HTML (not one php tag), or just the <? phpinfo(); ?>.

The PHP behaves fine when used with Apache-Win32, or from the command-line.

I've never seen PHP (from versions 4.1.2 to 4.2.2) work on Win2K + IIS :(.
 [2002-09-26 20:06 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

 [2002-10-14 11:13 UTC] nathan_silva at hotmail dot com
Sniper, the reason nobody gave feedback is because *nobody is using PHP ISAPI anymore*. I just tested this again with the latest 4.3.0-dev snapshot on Win2K. It still gives an AV. Here is how to duplicate it:

  1. Create a file with the following line: <?php phpinfo(); ?>
  2. From your web browser, access that file.
  3. Press refresh repeatedly until you see an access violation.

As j.mak said, no version of PHP ISAPI from 4.1.2 to present has worked.
 [2002-10-14 12:43 UTC]
Reopening as per comments
 [2002-10-14 18:40 UTC]
updated version. (even as this is most likely not even any bug in PHP but something in windows. Just use works)

 [2002-10-22 06:08 UTC] fallx at lycos dot com
I'm trying to use the Webfroot Shoutbox script for testing purposes.This had happened to me about everytime I tried to execute the script.

I'm using PHP 4.2.3 and Windows XP. Today, I finally able to stop the error from reproducing by changing the settings in php.ini register_globals = Off to register_globals = On.
 [2002-10-24 13:31 UTC] mattww3 at hotmail dot com
Dual Proc Win2k sp2+hotfixes...

4.2.3 as CGI no prob.  As ISAPI Same prob as everyone else works for a few minutes then...  access violations... then ISAPI stops responding but I have a virtual DIR with set as CGI and that continues working...

can be seen with the simple phpinfo.php idea.  

Please continue to investigate.   


Matt W.
 [2002-10-24 14:28 UTC] fallx at lycos dot com
Ran into this bug again. This happens either when I'm using the old style of using global variables or repeatedly accessing codes that have mistakes.
 [2002-10-28 13:52 UTC] bdbourn at qualityonewoodwork dot com
We are locked in to using IIS with Crystal Reports ASP for web reporting.  When I run PHP in CGI mode I experience some problems with pages rendering with errors (if anyone has suggestions in that area I would love to hear them) - pages will occasionally render with slightly scrambles source code ... javascript visible in the browser, html visible in the browser, form fields in the wrong place or the wrong size.

When PHP is run as an ISAPI mod all of the page scrambling problems go away.  However, my ASP apps start failing.

Here are the server stats:

PHP Version 4.2.3
Windows NT 5.0 build 2195
 [2002-10-29 08:28 UTC] mattww3 at hotmail dot com
regarding the asp not loading with php as ISAPI...

Try commenting out all the extra loaded extensions in php.ini. (execpt ones that are in use and necessary)

I had to do this to fix a form submit problem running in .cgi mode that stripped off characters on submit from normal form posts in PostNuke.

This also made the access violations much much less frequent for ISAPI.
 [2002-11-05 03:52 UTC] darkwings at 263 dot sina dot com
I think this may be caused by some memory used for each page
loading,these memory are allocated but not being released properly.
May be the environment variables used.
The memory leap accumulated until crash the IIS.

Any thing done when a page loaded need to be noticed.
 [2002-11-06 12:52 UTC] khaecki at datacomm dot ch
I get same error but also with different function:

php4ts!zend_strndup + 0x2B
 + 0xA05D8578

php4ts!zend_hash_copy + 0x1B
 + 0xA05D8578

There is a curious connection:

Under applications-configuration (i do not now the english correct name)
(where to install php4isapi.dll)
Dlg-page: applications-options (seems concerning ASP)

After deselecting "Buffer", IIS run very stable with no more interruption.

Mayby tray also..
 [2002-11-07 10:01 UTC] khaecki at datacomm dot ch
attachment to previous message:

>> There is a curious connection:
>> Under applications-configuration...

also not the best.., dit crash aniway.
 [2002-11-18 18:10 UTC] ruslan at snip dot com dot ua

i have been working on this a couple of days for now, and here are some facts i noticed after a couple of work-arounds...

- the error occurs only on systems with Win2K (SP >= 2)
- the error WILL NOT occur if logged in as system administrator, and the IIS security is turned to LOW !!
- the error will occur on EACH request if you fronpage extensions installed, and a global.asa file exists on the root .
- please keep us informed of a solution

 [2002-11-20 14:30 UTC] ryanphp at ryanjameson dot com
Add me to the list of people experiencing this. After a little while of switching back and forth from AV to 
working it goes to not responding at all. :-(
 [2002-11-27 09:16 UTC] nytral at spamcop dot net
Same issue, and even worse: 
since the last MS updates (IIS, SQL, MDAC), I get a bunch 
of access violations that I almost never got before. 
And running manually php.cgi causes the script to quit at 
the first SQL request, without warning/errors. It says 
'missing cgi headers' when running under php-cgi. 
I tried 4.3.0RC1, 4.3.0-dev, 4.4.0-dev (yesterday's 
snapshots), all the same result. 
Any PHP developper using a dual cpu Win2K platform could 
test/fix this?
 [2002-11-27 14:37 UTC] kees at boekel-it dot nl
We had the same "php4ts!zend_strndup + 0x2B + 0xA05CB1AD." error on our win2k server iis5 and php4.2.1.
Stan.nospam, and maybe others as well mentioned about setting isapi filters.
We added an isapi filter pointing to the same php4isapi.dll as in the apps mappings. The application which was hanging every 5 minutes before, didn't hang since (which is for 4 days now)
 [2002-12-01 16:19 UTC] shane dot hyde at apcairsea dot com dot au
I can easily reproduce this.  With a simple <? phpinfo(); ?> 5 refreshes kills PHP and inetinfo.  I have narrowed it down to a auto_prepend_file setting in php.ini.  With that setting disabled then I cannot crash it.  Hope this helps.
 [2002-12-08 17:32 UTC]
Please try using this CVS snapshot:
For Windows:

There was patch commited to the CVS on 2002/12/02 that may have solved the problem.
 [2002-12-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-12-26 09:06 UTC] mradamcole at hotmail dot com
I too have experienced this problem. I installed PHP4.2.3 on XP using ISAPI and PHPBB2.0.3.

Everything worked fine and I was quite excited about my budding relationship with PHP when... I installed the PHPBB Attachment Mod 2.3.4 ( and then I would notice RAM utilization would max out, heavy disk thrashing, and then ~30s later an AV crash.

Hope this helps.
 [2002-12-26 09:11 UTC] mradamcole at hotmail dot com
[Continued from my previous post]

...I forgot to add that setting the IIS Security to Low (IIS Process) allowed me to view more pages in the Attachment Mod of PHPBB2, but any time I tried to view a posting, even the first time, I would receive an AV.
 [2002-12-27 14:13 UTC] nathan_silva at hotmail dot com
Whatever the fix was, it seems to have done the job! I have only done about 10 minutes of testing but so far ISAPI is working.
 [2002-12-27 14:24 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 15:01:29 2024 UTC