litespeed-quic/tests
Paul Jakma 188c055a9c
Test case and fix for lsquic rechist list problem (#410)
* Test case and debug for lsquic rechist list problem

Add:
- test case
- debug rechist print function (not called)
Modify:
- rechist_test_sanity to be more robust

Test case:
Added test case which produces a corrupt rechist.  The rechist
grows and then is emptied, then a rechist is produced that is nominally
empty (rh_n_used == 0) but has a circular list in rh_elems.  E.g.  (using
debug print at the problem site):

lsquic_rechist_received: insert before done
0x7ffe65ce75a0: cutoff 9 l. acked 12087061905995 masks 1 alloced 4 used 1 max ranges 0 head 0
  (0)[9-9] (0)[9-9] (0)[9-9] (0)[9-9] (0)[9-9] (0)[9-9] (0)[9-9]
test_rechist: /tmp/lsquic/src/liblsquic/lsquic_rechist.c:272: rechist_test_sanity: Assertion `rechist->rh_n_used == n_elems' failed.

Debug print:
Added 'rechist_dump' for ease of debugging, marked as unused.
Useful for calling from gdb or adding to code temporarily.

rechist_test_sanity:
Make it more robust to bad rechists by limiting
how many list items it will follow, to prevent infinite loops or walking off
the end of the list.

* rechist: Fix bug in lsquic_rechist_received causing circular list to be created

Fix bug in lsquic_rechist_received demonstrated by the test6 test-case.

When the list is empty, i.e.  rh_n_used == 0, the 'first_elem' path should
be used.  However, the test for this was using rh_n_alloced, which would
cause the code to continue on incorrectly.  One possibility is that it goes
to insert_before and creates a circular list in the rechist with the head at
index 0 having a next of 0.

This causes history to be lost I think.

The list at this point is still 'empty', however a following call could go
to the insert_before path and then insert an elem pointing to the circular
list, and bump up rh_n_used. Now you have a circular list.

Weird things can happen now.  Notably, ACK generation will exhaust the
packet buffer and generate an error, and so cause connections to be
prematurely aborted.

Fix lsquic_rechist_received to use rh_n_used. Also modify
rechist_alloc_elem to NULL the next pointer for robustness.

It would be nice for rechist_free_elem to also invalidate the elem, but it
is meant for relinking elems in the list and should preserve the next
pointer.
2022-08-26 09:15:35 -04:00
..
CMakeLists.txt Release 3.1.0 2022-05-06 12:49:46 -04:00
graph_cubic.c Release 3.1.0 2022-05-06 12:49:46 -04:00
mini_parse.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ack.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ack_merge.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ackgen_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ackgen_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_ackparse_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ackparse_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_ackparse_ietf.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_alarmset.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_alt_svc_ver.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_arr.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_attq.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_blocked_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_blocked_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_bw_sampler.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_chlo_gen.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_clear_aead.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_conn_close_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_conn_close_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_conn_hash.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_crypto_gen.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_cubic.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_dec.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_di_nocopy.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_elision.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_engine_ctor.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_export_key.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_frame_chop.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_frame_reader.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_frame_rw.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_frame_writer.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_goaway_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_goaway_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_h3_framing.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_hcsi_reader.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_hkdf.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_hpi.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_lsquic_hash.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_malo.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_min_heap.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_minmax.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_packet_out.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_packet_resize.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_packno_len.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_parse_packet_in.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_purga.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_qlog.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_quic_be_floats.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_quic_le_floats.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_rechist.c Test case and fix for lsquic rechist list problem (#410) 2022-08-26 09:15:35 -04:00
test_reg_pkt_headergen.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_rst_stream_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_rst_stream_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_rst_stream_ietf.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_rtt.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_send_headers.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_senhist.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_set.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_sfcw.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_shi.c Release 3.1.2 2022-08-16 12:16:46 -04:00
test_some_packets.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_spi.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_stop_waiting_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_stop_waiting_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00
test_stream.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_streamgen.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_streamparse.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_tokgen.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_trapa.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_trechist.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_varint.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_ver_nego.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_wuf_gquic_be.c Release 3.1.0 2022-05-06 12:49:46 -04:00
test_wuf_gquic_le.c Rename test/unittests to tests/ and test/ to bin/ 2020-05-17 12:42:32 -04:00