From c454a0659050044767b3acb89a9a70bb289cb014 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Fri, 1 Dec 2023 13:31:13 +0000 Subject: [PATCH] tpu_reasm: add regression test for chunk aliasing Regression tests a bug fixed in https://github.com/firedancer-io/firedancer/pull/1021 where the data regions of slots were overlapping. --- src/disco/quic/test_tpu_reasm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/disco/quic/test_tpu_reasm.c b/src/disco/quic/test_tpu_reasm.c index 3e97aa3544..7c7d9f7854 100644 --- a/src/disco/quic/test_tpu_reasm.c +++ b/src/disco/quic/test_tpu_reasm.c @@ -1,4 +1,5 @@ #include "fd_tpu.h" +#include "fd_tpu_reasm_private.h" /* An arbitrary valid transaction */ FD_IMPORT_BINARY( transaction4, "src/ballet/txn/fixtures/transaction4.bin" ); @@ -118,6 +119,35 @@ main( int argc, verify_state( reasm, mcache ); + /* Confirm that memory regions are within bounds */ + + FD_TEST( reasm->slots_off + (slot_cnt * sizeof(fd_tpu_reasm_slot_t)) <= sizeof(tpu_reasm_mem) ); + FD_TEST( reasm->chunks_off + (slot_cnt * FD_TPU_REASM_MTU) <= sizeof(tpu_reasm_mem) ); + + /* Confirm that the data regions of slots don't overlap */ + + memset( (uchar *)( (ulong)reasm + reasm->chunks_off ), 0, slot_cnt * FD_TPU_REASM_MTU ); + + for( ulong j=0UL; j= (ulong)reasm + reasm->chunks_off ); + FD_TEST( (ulong)data + FD_TPU_REASM_MTU <= (ulong)reasm + sizeof(tpu_reasm_mem) ); + + for( ulong b=0UL; b