Hi! I'm in the process of implementing a custom php_stream that has to do some things to meet our demands. I have already gotten it to (mostly) work (php 5.2.19, just in case.... I will move to later versions when we move our PHP codebase to 5.3 and 5.4 so please bear with me... probably the issue is the same for later API versions) but I'm hitting a SIGSEGV that I bet is happening because I'm short-circuiting the php_stream process and probably skipping some required things that are making php explote.
Program received signal SIGSEGV, Segmentation fault. zend_mm_remove_from_free_list (heap=0x84711f8, mm_block=0x88dd7bc) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_alloc.c:837 837 if (UNEXPECTED(prev->next_free_block != mm_block) || UNEXPECTED(next->prev_free_block != mm_block)) { (gdb) backtrace #0 zend_mm_remove_from_free_list (heap=0x84711f8, mm_block=0x88dd7bc) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_alloc.c:837 #1 0x0828bbcb in _zend_mm_free_int (heap=0x84711f8, p=0x88dd7c4) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_alloc.c:1979 #2 0x0827b5a6 in php_stdiop_close (stream=0x88deca0, close_handle=0) at /home/antoranz/Descargas/php/php-5.2.17/main/streams/plain_wrapper.c:432 #3 0x082780fa in _php_stream_free (stream=0x88deca0, close_options=11) at /home/antoranz/Descargas/php/php-5.2.17/main/streams/streams.c:283 #4 0x08278529 in stream_resource_regular_dtor (rsrc=0x88ded24) at /home/antoranz/Descargas/php/php-5.2.17/main/streams/streams.c:1426 #5 0x082b2acc in list_entry_destructor (ptr=0x88ded24) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_list.c:184 #6 0x082afdf5 in zend_hash_apply_deleter (ht=0x846fec0, p=0x88dec74) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_hash.c:611 #7 0x082b11f7 in zend_hash_graceful_reverse_destroy (ht=0x846fec0) at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend_hash.c:646 #8 0x082a67fd in zend_deactivate () at /home/antoranz/Descargas/php/php-5.2.17/Zend/zend.c:866 #9 0x08263a56 in php_request_shutdown (dummy=0x0) at /home/antoranz/Descargas/php/php-5.2.17/main/main.c:1504 #10 0x0808b0f7 in main (argc=2, argv=0xbffff214) at /home/antoranz/Descargas/php/php-5.2.17/sapi/cli/php_cli.c:1346 What I'm doing at the moment is: - Detour in the beginning of _php_stream_fopen_with_path to see if the file requested can be handled by my php_stream. If it can, I just create a struct our_structure (which has a struct php_stream member) with emalloc(), I populate the our_structure instance with whatever we need, I create a new struct php_stream_ops instance (again, with emalloc), set its read, write, seek, close, flush prototypes to our custom functions for that, set the php_stream's ops of our our_structure to this new ops instance.... if everything is OK, I just return this php_stream from _php_stream_fopen_with_path _without_ doing any of its later processing. Under some conditions (for example, when most of the scripts I need to run are handled by our custom php_stream) it works, no complains from php.... in this case it's crashing because one script can't be found (which means that it's following PHP's normal flow to find a php script). So.... long story short: what things do I have to keep in mind when I create a new kind of php_stream? Perhaps there's a safer way to do this? Thanks in advance. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php