maskit commented on code in PR #14017:
URL: https://github.com/apache/trafficserver/pull/14017#discussion_r4521283674
##########
include/iocore/net/quic/QUICStream.h:
##########
@@ -76,6 +76,8 @@ class QUICStream
bool is_bidirectional() const;
bool has_no_more_data() const;
bool has_data_to_send();
+ /// Whether the FIN that ends this stream's send side has been handed to the
transport.
+ bool is_fin_sent() const;
Review Comment:
The new `is_fin_sent()` check relies on `QUICStreamIO::write_stream()`
committing the FIN only when it writes the whole buffer. quiche, QMux and
OpenSSL all behave that way today. Could you document that on the interface?
##########
src/iocore/net/quic/QUICStreamManager.cc:
##########
@@ -27,6 +27,12 @@
#include "iocore/net/quic/QUICTransportParameters.h"
#include "iocore/net/quic/QUICStream.h"
#include "iocore/net/quic/QUICStreamManager.h"
+#include "tsutil/DbgCtl.h"
+
+namespace
+{
+DbgCtl dbg_ctl{"quic_stream"};
Review Comment:
`QUICStream.h` already provides `QUICStreamDbgCtl::quic_stream()`. Please
use that instead of adding a second `DbgCtl` for the same tag.
##########
src/iocore/net/quic/QUICStreamVCAdapter.cc:
##########
@@ -377,7 +377,7 @@ QUICStreamVCAdapter::is_readable()
bool
QUICStreamVCAdapter::is_writable()
{
- return this->stream().direction() != QUICStreamDirection::RECEIVE;
+ return this->stream().direction() != QUICStreamDirection::RECEIVE &&
!this->stream().is_fin_sent();
Review Comment:
**Possible use-after-free after deleting on READ_COMPLETE**
This change lets `Http3App::_handle_bidi_stream_on_read_complete()` (not in
this diff) delete a bidirectional stream for the first time.
**Sequence:**
1. The client's FIN arrives while the last response bytes are still waiting
to be sent. `receive_data()` queues READ_COMPLETE.
2. `send_data()` sends the final FIN. `encourge_write()` queues
WRITE_COMPLETE behind the READ_COMPLETE.
3. READ_COMPLETE sees `!is_writable()` and deletes the `QUICStream`.
`on_stream_close()` keeps `IOInfo` alive because the transaction still exists.
4. WRITE_COMPLETE runs, and `main_event_handler()` calls `adapter->stream()`
on the deleted stream.
**Why nothing stops it:**
- Nothing on the delete path cancels the adapter's scheduled events.
- `HQTransaction::stream_closed()` doesn't call `adapter.do_io_close()`, so
the adapter's VIOs are still active.
**How likely:**
- OpenSSL backend: `_process_openssl_streams()` calls `receive_data()` and
then `send_data()` on the same stream in the same pass, so step 2 always
follows step 1.
- quiche backend: it needs a packet-write event that was already queued
ahead of the READ_COMPLETE.
**Ask:** cancel the adapter's pending events when the stream is deleted, or
have the handler stop touching `stream()` once the stream is closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]