Open GoogleCodeExporter opened 9 years ago
maybe a double free problem
Original comment by Liny...@gmail.com
on 23 Mar 2011 at 8:59
[deleted comment]
[deleted comment]
发现了崩溃的原因:
(magent.c r31版本)
函数process_get_response 1351行-1360行
if (s->valuebytes < 0) {
/* END\r\n or SERVER_ERROR\r\n
* just skip this transcation
*/
put_server_into_pool(s);
c->srv = NULL;
if (c->flag.is_last_key) out_string(c, "END");
do_transcation(c); /* TO Next KEY */
return;
}
如果out_string(c,
"END")中发生错误,c被释放,下一行执行do_transcation(c)将可能��
�生内存错误
Original comment by Liny...@gmail.com
on 28 Mar 2011 at 9:04
[deleted comment]
附件为我在r31版本基础上修改的magent.c
以下为diff:
245c245
< static int out_string(conn *, const char *);
---
> static void out_string(conn *, const char *);
695,698c695
< if (c->srv) {
< server_free(c->srv);
< c->srv = NULL;
< }
---
> server_free(c->srv);
805c802
< static int
---
> static void
812c809
< if (c == NULL || str == NULL || str[0] == '\0') return -1;
---
> if (c == NULL || str == NULL || str[0] == '\0') return;
817c814
< if (b == NULL) return -1;
---
> if (b == NULL) return;
837d833
< return -1;
839d834
< return 0;
1179d1173
< c->srv = NULL;
1352d1345
< return;
1364,1367c1357
< if (c->flag.is_last_key) {
< if (out_string(c, "END") == -1)
< return;
< }
---
> if (c->flag.is_last_key) out_string(c, "END");
1620d1609
< if (b == NULL) return;
1652,1655c1641
< if (out_string(c, "SERVER_ERROR OUT OF MEMORY") == -1) {
< buffer_free(b);
< return;
< }
---
> out_string(c, "SERVER_ERROR OUT OF MEMORY");
1751,1754c1737
< if (out_string(c, "memcached agent v" VERSION) == -1) {
< buffer_free(b);
< return;
< }
---
> out_string(c, "memcached agent v" VERSION);
1758,1765c1741
< if (out_string(c, tmp) == -1) {
< buffer_free(b);
< return;
< }
< }
< if (out_string(c, "END") == -1) {
< buffer_free(b);
< return;
---
> out_string(c, tmp);
1766a1743
> out_string(c, "END");
1773,1776c1750
< if (out_string(c, "VERSION memcached agent v" VERSION) == -1) {
< buffer_free(b);
< return;
< }
---
> out_string(c, "VERSION memcached agent v" VERSION);
1779,1782c1753
< if (out_string(c, "UNSUPPORTED COMMAND") == -1) {
< buffer_free(b);
< return;
< }
---
> out_string(c, "UNSUPPORTED COMMAND");
Original comment by Liny...@gmail.com
on 28 Mar 2011 at 9:17
Attachments:
Original issue reported on code.google.com by
Liny...@gmail.com
on 22 Mar 2011 at 2:42