Re: [PHP4BETA] Sybase-CT memory leaks and crashes

From: Date: Fri, 19 Nov 1999 13:04:10 +0000
Subject: Re: [PHP4BETA] Sybase-CT memory leaks and crashes
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-6486@lists.php.net to get a copy of this message
There was indeed a problem, but your fix wasn't quite right (as far as I can tell from first glance, it's pure coincidence that it worked and didn't crash :) I committed a one liner fix to the original problem, but since I don't have access to a Sybase server for quite a while now, I can't test it. If you can test the latest CVS and let me know how well it works, it'd be great. Zeev On Fri, 19 Nov 1999 richard@iguana.co.nz wrote: > Having tried both beta2 and beta3 out on development boxes for the site I > administer, I noticed massive (150mb+) error logs being generated by > Apache regarding small (2->4byte) memory leaks, and a large number of > segfaults and overruns by various parts of Zend. On a hunch, I dug out the > sybase-ct ext code and rewrote part of the php_sybase_fetch_hash function, > and much to my surprise (I follow a lot of hunches, but they only rarely > turn out to be right first time) it appears to have solved the problem > entirely. > > I'm not a frequent programmer in the php4 source, so I don't pretend > that this is necessarily the best way, or even a good way to solve it > :) nor do I usually follow this list, however I was unable to find any > other way of submitting a fix without a cvs uid/pwd. > > The function now reads: > > ----------- > > static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS) > { > pval *sybase_result_index; > sybase_result *result; > int i; int should_copy; > pval *tmp; > PLS_FETCH(); > > if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &sybase_result_index)==FAILURE) { > WRONG_PARAM_COUNT; > } > > ZEND_FETCH_RESOURCE(result, sybase_result *, &sybase_result_index, -1, "Sybase > result", sybase_globals.le_result); > > if (result->cur_row >= result->num_rows) { > RETURN_FALSE; > } > > if (array_init(return_value)==FAILURE) { > RETURN_FALSE; > } > > for (i=0; i<result->num_fields; i++) { > char *data; > int data_len; > tmp = &result->data[result->cur_row][i]; > > if (PG(magic_quotes_runtime)) { > data = php_addslashes(tmp->value.str.val,tmp->value.str.len,&data_len,0); > should_copy = 0; > } else { > data = tmp->value.str.val; > data_len = tmp->value.str.len; > should_copy = 1; > } > > add_index_stringl(return_value,i,data,data_len,should_copy); > should_copy = 1; > add_assoc_stringl(return_value,result->fields[i].name,data,data_len,should_copy); > > /* ---- Old code here ---- > tmp = (pval *) emalloc(sizeof(pval)); > *tmp = result->data[result->cur_row][i]; > INIT_PZVAL(tmp); > pval_copy_constructor(tmp); > if (PG(magic_quotes_runtime) && tmp->type == IS_STRING) { > tmp->value.str.val = > php_addslashes(tmp->value.str.val,tmp->value.str.len,&tmp->value.str.len,1); > } > zend_hash_index_update(return_value->value.ht, i, (void *) &tmp, sizeof(pval *), > NULL); > zend_hash_update(return_value->value.ht, result->fields[i].name, > strlen(result->fields[i].name)+1, (void *) &tmp, sizeof(pval *), NULL); > */ > } > result->cur_row++; > } > > ---------- > > > Richard Clark, > Iguana Information Services. > richard@iguana.co.nz > > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net > -- ----------------------------------------------------- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.version4 (#6486) next »