@@ -999,9 +999,9 @@ class TestBinaryFormatValidation(BinaryFormatTestBase):
999999 """Tests for malformed binary files."""
10001000
10011001 HDR_OFF_SAMPLES = 28
1002- HDR_OFF_THREADS = 32
1003- HDR_OFF_STR_TABLE = 36
1004- HDR_OFF_FRAME_TABLE = 44
1002+ HDR_OFF_THREADS = 36
1003+ HDR_OFF_STR_TABLE = 40
1004+ HDR_OFF_FRAME_TABLE = 48
10051005 FILE_HEADER_PLACEHOLDER_SIZE = 64
10061006 FILE_FOOTER_SIZE = 32
10071007 FTR_OFF_STRINGS = 0
@@ -1039,7 +1039,7 @@ def test_replay_rejects_sample_count_mismatch(self):
10391039
10401040 with open (filename , "r+b" ) as raw :
10411041 raw .seek (self .HDR_OFF_SAMPLES )
1042- raw .write (struct .pack ("=I " , 2 ))
1042+ raw .write (struct .pack ("=Q " , 2 ))
10431043
10441044 with BinaryReader (filename ) as reader :
10451045 self .assertEqual (reader .get_info ()["sample_count" ], 2 )
@@ -1149,6 +1149,31 @@ def test_open_accepts_frame_count_at_capacity_boundary(self):
11491149 f"possible { max_frames } " ,
11501150 )
11511151
1152+ def test_sample_count_reads_full_64_bits (self ):
1153+ """sample_count values requiring the upper 32 bits decode correctly."""
1154+ filename = self .create_binary_file ([], compression = "none" )
1155+ big_count = 0x1_0002_0003
1156+
1157+ with open (filename , "r+b" ) as raw :
1158+ raw .seek (self .HDR_OFF_SAMPLES )
1159+ raw .write (struct .pack ("=Q" , big_count ))
1160+
1161+ with BinaryReader (filename ) as reader :
1162+ self .assertEqual (reader .get_info ()["sample_count" ], big_count )
1163+
1164+ def test_sample_count_boundary_values (self ):
1165+ """Values above the old u32 ceiling decode fine."""
1166+ filename = self .create_binary_file ([], compression = "none" )
1167+
1168+ for value in (0xFFFFFFFF - 1 , 0xFFFFFFFF , 0xFFFFFFFF + 1 ):
1169+ with self .subTest (value = value ):
1170+ with open (filename , "r+b" ) as raw :
1171+ raw .seek (self .HDR_OFF_SAMPLES )
1172+ raw .write (struct .pack ("=Q" , value ))
1173+
1174+ with BinaryReader (filename ) as reader :
1175+ self .assertEqual (reader .get_info ()["sample_count" ], value )
1176+
11521177
11531178class TestBinaryEncodings (BinaryFormatTestBase ):
11541179 """Tests specifically targeting different stack encodings."""
0 commit comments