alibaba / xquic

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.
Apache License 2.0
1.65k stars 326 forks source link

[Bug]: xqc_h3_request_send_body导致的内存不断增长问题 #245

Open adcen0107 opened 1 year ago

adcen0107 commented 1 year ago

What happened?

1、xqc_h3_request_send_body 发送http数据,最终进入如下函数: https://github.com/alibaba/xquic/blob/00f622885d91e02c879f8531bc04af7a584faed4/src/http3/xqc_h3_stream.c#L218 / write DATA frame / ret = xqc_h3_frm_write_data(&h3s->send_buf, data + write, size, flag); if (ret != XQC_OK) { xqc_log(h3s->log, XQC_LOG_ERROR, "|write DATA frame error|%d|stream_id:%ui|fin:%d|", ret, h3s->stream_id, (unsigned int)fin); return ret; } write += size; xqc_log_event(h3s->log, HTTP_FRAME_CREATED, h3s, XQC_H3_FRM_DATA, size);

    /* send DATA frame */
    ret = xqc_h3_stream_send_buffer(h3s);

2、xqc_h3_frm_write_data 将data不断拷到内存并添加到send-buf链表; 3、xqc_h3_stream_send_buffer 不断消耗h3s->send_buf链表的buf,若quic层传输速率过小,远小于应用层写入数据速率,且应用层不断写入数据,最终会导致数据在h3s->send_buf不断堆积,内存消耗越来越大,程序出错。

Steps To Reproduce

1、限制发送端到接收端的链路带宽为1Mbps; 2、发送端同一个流不断调用 xqc_h3_request_send_body 发数据; 3、可以观察到h3s->send_buf链表不断增长,内存不断增大,最终程序被系统kill掉。

Relevant log output

No response