Skip to content

Commit

Permalink
tpu_reasm: add regression test for chunk aliasing
Browse files Browse the repository at this point in the history
Regression tests a bug fixed in #1021
where the data regions of slots were overlapping.
  • Loading branch information
riptl authored and ripatel-fd committed Dec 1, 2023
1 parent 6c67ab7 commit c454a06
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/disco/quic/test_tpu_reasm.c
Original file line number Diff line number Diff line change
@@ -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" );
Expand Down Expand Up @@ -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<burst; j++ ) {
fd_tpu_reasm_slot_t * slot = fd_tpu_reasm_prepare( reasm, 0UL );
FD_TEST( slot );
uint idx = slot_get_idx( reasm, slot );

uchar * data = slot_get_data( reasm, idx );
FD_TEST( (ulong)data >= (ulong)reasm + reasm->chunks_off );
FD_TEST( (ulong)data + FD_TPU_REASM_MTU <= (ulong)reasm + sizeof(tpu_reasm_mem) );

for( ulong b=0UL; b<FD_TPU_REASM_MTU; b++ )
FD_TEST( data[b]==0 );

memset( data, 0xFF, FD_TPU_REASM_MTU );
}

/* Reininitalize */

fd_tpu_reasm_reset( reasm, mcache );
verify_state( reasm, mcache );

/* Confirm that invalid transactions don't get published */

do {
Expand Down

0 comments on commit c454a06

Please sign in to comment.