Re: Re: Segfault

From: Date: Sat, 17 Sep 2005 17:50:37 +0000
Subject: Re: Re: Segfault
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-19069@lists.php.net to get a copy of this message
What I meant to say was that I did use zend_fetch_list_dtor_id in RINIT at first, but I noticed that PHP was not calling RINIT. So then I migrated it MINIT, which is called when the module is loaded. Doubtful... PHP calls every module's RINIT at the start of every request. If you were "testing" RINIT by launching something like php -m or php -i or something then sure RINIT wouldn't be called. There's no actual request involved. In a real script execute it most certainly would call RINIT.
As for malloc/emalloc, I tried using malloc(sizeof(struct php_socket)); which did not work because gcc was erroring with "Incomplete datatype". I then re-read the Zend API function list and came across emalloc, which I had omitted when I first read it. So once I used emalloc, it worked. The malloc/emalloc issue is genuine enough in that yes, you do need to be using the emalloc() family over the system malloc allocators (except in rare cases involving persistency).
The larger issue of the incomplete type comes from the fact that the form of your structure declaration means you'll want to get your size from sizeof(php_socket) not sizeof(struct php_socket). typedef struct {
       PHP_SOCKET bsd_socket;
       int             type;
       int             error;
} php_socket;

« previous php.internals (#19069) next »