Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Why my php extension crashed with stack overflow? |
|
Author |
|
kimryo
Joined: 26 Dec 2007 Posts: 4
|
Posted: Wed 26 Dec '07 3:12 Post subject: Why my php extension crashed with stack overflow? |
|
|
My php extension just invoked several functions exported by a regular DLL,for most functions in those exported invoked,my php extension just works well,but when invoke a function which require a comparatively large memory(about less than 30M memory taken),my httpd.exe crashed with a stack overflow reason.And the function itself is ok to invoke by other applications like VB client etc.
My php is integrated with Apache as a module.Is here any memory limitation on addon modules?
My env is,Apache 2.2.6,Php 5.2.5,Windows XP SP2,Administrator account;
Any suggestion is appreciate. |
|
Back to top |
|
kimryo
Joined: 26 Dec 2007 Posts: 4
|
Posted: Fri 28 Dec '07 3:23 Post subject: |
|
|
I've tried just now with replacing Apache to IIS,and it is ok to run my php extension,what's wrong with Apache? Could any one tell?Thanks in advance. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 28 Dec '07 5:46 Post subject: |
|
|
Unfortunately a vague description like "functions exported by a regular DLL" is not nearly enough to to reproduce your problem, or to diagnose it.
In general - Apache imposes no memory limitations on modules.
Most stack overflows on Windows are caused by a function calling itself recursively - but other causes are possible.
-tom- |
|
Back to top |
|
kimryo
Joined: 26 Dec 2007 Posts: 4
|
Posted: Fri 28 Dec '07 6:21 Post subject: |
|
|
tdonovan wrote: | Unfortunately a vague description like "functions exported by a regular DLL" is not nearly enough to to reproduce your problem, or to diagnose it.
In general - Apache imposes no memory limitations on modules.
Most stack overflows on Windows are caused by a function calling itself recursively - but other causes are possible.
-tom- |
emm...I've wrote a library in C++ to process images,like format conversion etc,and pack these functions into a DLL.This DLL it is called by many types of client,like VB app and VC app,and runs well.
Now I just wrote a php extension to port these functions,makes them can be called by php script easily.Some of the functions,just performs regularly;while some makes httpd.exe crashed with stack overflow reason,crash point is right in my library DLL.The obvious difference between the two kind of functions is the amount of memory they consumed:the second type of functions consume more memory than first.
And if replace Apache with IIS,there is no crash any more. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 28 Dec '07 16:36 Post subject: |
|
|
re: "I've wrote a library in C++ to process images..."
Maybe you are putting very large data (for example, image data) into local variables which use the stack, instead of using heap variables (new/delete in C++).
You can often get away with this mistake in single-threaded stand-alone programs, but it can cause problems in multi-threaded server programs like Apache.
Two things you can try: Code: | EDITBIN /STACK:0x500000,0x10000 httpd.exe |
2. - Use an Apache module like mod_fcgid or mod_fastcgi to run PHP in an external process (like IIS does), rather than running PHP inside the Apache process.If either of these things correct the problem, it is an indication that your library does indeed use an excessive amount of stack space.
In this case, it would be better to change your code to put large data into heap space rather than stack space.
-tom- |
|
Back to top |
|
kimryo
Joined: 26 Dec 2007 Posts: 4
|
Posted: Fri 28 Dec '07 17:02 Post subject: |
|
|
tdonovan wrote: | re: "I've wrote a library in C++ to process images..."
Maybe you are putting very large ...
-tom- |
thanks! |
|
Back to top |
|
|
|
|
|
|