|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-09 03:12 UTC] wmeler at wp-sa dot pl
Description:
------------
My application uses fsockopen. Since streams has been introduced I notice SIG_SEGVs. As you can see below stack is corrupted and stream memory is freed (if it is really it's memory)
(gdb) bt full
#0 _php_stream_flush (stream=Error accessing memory address 0xb71fd09c: No such process.
) at /home/wmeler/rpm/BUILD/aris-1.6/php/main/streams.c:875
stream = (php_stream *) 0x4a9ce250
tsrm_ls = (void ***) 0x8779ef0
ret = 0
Error accessing memory address 0xb71fd094: No such process.
(gdb) print *(php_stream *) 0x4a9ce250
$1 = {ops = 0x4652c678, abstract = 0x1, filterhead = 0x10003, filtertail = 0x2a8fcc84,
wrapper = 0x5a5a5a5a, wrapperthis = 0x3d, wrapperdata = 0x4e6a3ec0,
fgetss_state = 135898848, is_persistent = 110,
mode = "\001", '\000' <repeats 11 times>, ": \a", rsrc_id = 1251795496, in_free = 1,
fclose_stdiocast = 2, stdiocast = 0xcc840030, __exposed = 1515858575,
__orig_path = 0x5a5a5a5a <Error reading address 0x5a5a5a5a: No such process>,
context = 0x31, flags = 1279301096, position = 1185939604,
readbuf = 0x5a5a5a5a <Error reading address 0x5a5a5a5a: No such process>,
readbuflen = 1515870810, readpos = 1515870810, writepos = 1515870810,
chunk_size = 1515870810, eof = 1515870810}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
after turning on STREAMS_DEBUG I've got better core: #0 0x08088603 in _php_stream_free (stream=0x45c22290, close_options=11, tsrm_ls=0x8523d68) at /home/wmeler/rpm/BUILD/aris-1.6/php/main/streams.c:294 #1 0x0808b12f in stream_resource_regular_dtor (rsrc=0x46c50910, tsrm_ls=0x8523d68) at /home/wmeler/rpm/BUILD/aris-1.6/php/main/streams.c:2291 #2 0x080ad2e2 in list_entry_destructor (ptr=0x46c50910) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_list.c:177 #3 0x080ab8e0 in zend_hash_del_key_or_index (ht=0x8862ccc, arKey=0x0, nKeyLength=0, h=5, flag=1) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_hash.c:514 #4 0x080ad0a4 in _zend_list_delete (id=5, tsrm_ls=0x8523d68) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_list.c:56 #5 0x080a5ac2 in _zval_dtor (zvalue=0x46c502d8, __zend_filename=0x8199080 "/home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_execute_API.c", __zend_lineno=291) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_variables.c:69 #6 0x0809e27e in _zval_ptr_dtor (zval_ptr=0x45c01010, __zend_filename=0x8195c60 "/home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_execute.h", __zend_lineno=96) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_execute_API.c:291 #7 0x080bbcbd in execute (op_array=0x429d5ee0, tsrm_ls=0x8523d68) at /home/wmeler/rpm/BUILD/aris-1.6/php/Zend/zend_execute.h:96 The function called from PHP userspace was fclose. I also found in log 1069 msg looks like: stream_alloc: socket:0x43d64f08 persistent=(null) and only 48 msg pairs like: stream_free: socket:0x4849caf8[(null)] in_free=0 opts=00000003 stream_free: socket:0x4849caf8[(null)] preserve_handle=0 release_cast=1 remove_rsrc=1 I also got about 40 core dumps. If you want more information please describe what kind of information you want.There are sill some issues with streams. Now pfsockopen causes segfaults on php4-STABLE-200307280730 : ./configure ---disable-all --enable-debug .... ./make ..... ./sapi/cli/php -r '$f=pfsockopen("www.php.net",80,$errno,$errmsg,2);fputs($f,"SHIT\r\n\r\n");fpassthru($f);fclose($f);' <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>301 Moved Permanently</TITLE> </HEAD><BODY> <H1>Moved Permanently</H1> The document has moved <A HREF="http://www.php.net/">here</A>.<P> </BODY></HTML> Segmentation fault (core dumped) ./gdb -c core sapi/php/cli bt #0 0x40128c25 in __libc_free (mem=0x816c038) at malloc.c:3155 #1 0x80f8edb in zend_hash_apply_deleter (ht=0x8143314, p=0x816c148) at /tmp/php4-STABLE-200307280730/Zend/zend_hash.c:601 #2 0x80f90ea in zend_hash_graceful_reverse_destroy (ht=0x8143314) at /tmp/php4-STABLE-200307280730/Zend/zend_hash.c:664 #3 0x80fab99 in zend_destroy_rsrc_list (ht=0x8143314) at /tmp/php4-STABLE-200307280730/Zend/zend_list.c:233 #4 0x80f30fb in zend_shutdown () at /tmp/php4-STABLE-200307280730/Zend/zend.c:555 #5 0x80c284b in php_module_shutdown () at /tmp/php4-STABLE-200307280730/main/main.c:1281 #6 0x8109c73 in main (argc=3, argv=0xbffff974) at /tmp/php4-STABLE-200307280730/sapi/cli/php_cli.c:877 #7 0x400c4507 in __libc_start_main (main=0x81091b8 <main>, argc=3, ubp_av=0xbffff974, init=0x8059760 <_init>, fini=0x810a250 <_fini>, rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbffff96c) at ../sysdeps/generic/libc-start.c:129 And I think you really should review php_stream_close usage. I'm sure that pclose function would cause the same problems as fclose caused before. All places that user can make reference to resource should use zend_list_delete.