Hi!

If this is not the group to discuss the issues of writing extensions please let me 
know, but for now I have a question:

What causes php to crash after 256 executions of my extension? / How can this be 
avoided?

The extension opens a file (on the server), writes some values into it and closes the 
file (yes, I did not forget the fclose!). 
I use the standard C file handling commands (fopen, ...). Additionally some mysql 
requests are done.

The whole extension works fine, it reads the right values, creates the file and stores 
the values in a correct way. It's just 
that it crashes after 256 executions.

With PHP used as a module it does not make a difference if the requests to the ext 
were made from one or from several  
pages. With PHP used as a cgi binary it crashes only if the requests were all done 
from one page.

The error messages are:

for the CGI binary:
"PHP caused an invalid page fault in PHP4TS.DLL"

for the module:
"APACHE caused an invalid page fault in PHP4TS.DLL"

In the first case APACHE continues to behave exactly like before the crash, and I get 
an Internal Sever Error,
if the latter case APACHE crashes again and again until I press the stop button of the 
browser.

I would be grateful If you could tell me were the error lies,

Basti

PS: some more useful information:

About the environment:
Windows 98 SE,
PHP 4.1.1,
Apache 1.3.14,
MySql 3.23 beta,
The extension was compiled using MS Visual C++ 6.0
The browser is running on the same machine as the servers.

Some part of the code:
FILE * open_matfile(char * mode){
        FILE * mf;

         mf=fopen("d:\\studium\\pilanesberg\\homepage\\matrix.dat", mode);
         if (!mf) {
                zend_printf("Error opening matrix file in mode %s: %i.<br>",mode, 
ferror(mf));
         }
        
         return (mf);
}

int store_matrix(int dMat[][MAXI], int nMat[][MAXI], int nodes[], int numOfNodes){     
 
        FILE *matFile;  //the matrix file

        matFile=open_matfile("wb");

{...}
                
        fclose(matFile);

        return(0);
}


int load_matrix(int dMat[][MAXI], int nMat[][MAXI], int nodes[MAXI/2]){ 
        FILE *matFile;

        matFile=open_matfile("rb");
        if (!matFile) {return(0);}

{...}
                        
        if (fclose(matFile)){
                zend_printf("Error closing matrix file<br>");
                return(0);
        }
                
{...}
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to