Changeset 286516 in webkit
- Timestamp:
- Dec 3, 2021 2:48:23 PM (2 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r286493 r286516 1 2021-12-03 Filip Pizlo <fpizlo@apple.com> 2 3 [libpas] Bitfit allocator has a wrong assertion when a page's max_free is enough for the size of an allocation, not enough for that allocation's size class, and the object of that size is not aligned to the currently requested alignment 4 https://bugs.webkit.org/show_bug.cgi?id=233831 5 6 Reviewed by Yusuke Suzuki. 7 8 What a combination of conditions: 9 10 - We just failed bitfit allocation in a page, which gives us some max_free (aka largest_available), and the allocation had nontrivial alignment. 11 - The max_free is smaller than the size class. 12 - The max_free is larger than the requested size. 13 - The max_free object is not aligned to the requested alignment. 14 15 The code handles this fine, but has a wrong assertion about it. 16 17 This change fixes the assertion and adds a test that deterministically reproduced the issue. 18 19 * libpas/libpas.xcodeproj/project.pbxproj: 20 * libpas/src/libpas/pas_bitfit_allocator.c: 21 (pas_bitfit_allocator_finish_failing): 22 * libpas/src/libpas/pas_bitfit_allocator_inlines.h: 23 (pas_bitfit_allocator_try_allocate): 24 * libpas/src/test/BitfitTests.cpp: Added. 25 (std::getBitfitSizeClasses): 26 (std::assertSizeClasses): 27 (std::testAllocateAlignedSmallerThanSizeClassAndSmallerThanLargestAvailable): 28 (addBitfitTests): 29 * libpas/src/test/TestHarness.cpp: 30 (main): 31 1 32 2021-12-02 Filip Pizlo <fpizlo@apple.com> 2 33 -
trunk/Source/bmalloc/libpas/libpas.xcodeproj/project.pbxproj
r286493 r286516 569 569 2C85DC4127128F0F00367905 /* pas_try_allocate_intrinsic.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C85DC4027128F0F00367905 /* pas_try_allocate_intrinsic.h */; }; 570 570 2C91E5502718DA9A00D67FF9 /* pas_size_lookup_mode.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C91E54F2718DA9A00D67FF9 /* pas_size_lookup_mode.h */; }; 571 2CE2AE35275A953E00D02BBC /* BitfitTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CE2AE34275A953E00D02BBC /* BitfitTests.cpp */; }; 571 572 /* End PBXBuildFile section */ 572 573 … … 1253 1254 2C85DC4027128F0F00367905 /* pas_try_allocate_intrinsic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pas_try_allocate_intrinsic.h; sourceTree = "<group>"; }; 1254 1255 2C91E54F2718DA9A00D67FF9 /* pas_size_lookup_mode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pas_size_lookup_mode.h; sourceTree = "<group>"; }; 1256 2CE2AE34275A953E00D02BBC /* BitfitTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitfitTests.cpp; sourceTree = "<group>"; }; 1255 1257 /* End PBXFileReference section */ 1256 1258 … … 1345 1347 children = ( 1346 1348 0FDEA45D228B651B0085E340 /* BitfieldVectorTests.cpp */, 1349 2CE2AE34275A953E00D02BBC /* BitfitTests.cpp */, 1347 1350 0F53181022C954ED003F7B6A /* BitvectorTests.cpp */, 1348 1351 0F31A66723E8B336002C0CA3 /* CartesianTreeTests.cpp */, … … 2585 2588 0FD48B6723B589910026C46D /* IsoHeapPartialAndBaselineTests.cpp in Sources */, 2586 2589 0F5B6094235E919900CAE629 /* IsoHeapReservedMemoryTests.cpp in Sources */, 2590 2CE2AE35275A953E00D02BBC /* BitfitTests.cpp in Sources */, 2587 2591 0F5193E7266AE5D400483A2C /* JITHeapTests.cpp in Sources */, 2588 2592 0FC64191213745FA0040CE5E /* LargeFreeHeapTests.cpp in Sources */, -
trunk/Source/bmalloc/libpas/src/libpas/pas_bitfit_allocator.c
r286493 r286516 206 206 pas_bitfit_page_config* config) 207 207 { 208 static const bool verbose = false; 209 208 210 pas_bitfit_directory* directory; 209 211 pas_bitfit_size_class* size_class; … … 222 224 223 225 view_index = view->index; 226 227 if (verbose) { 228 pas_log("Finishing failing in view %p, size = %zu, alignment = %zu, largest_available = %zu\n", 229 view, size, alignment, largest_available); 230 } 224 231 225 232 /* If we're still on the view that the allocator was on and we found that this view no longer … … 243 250 directory, index, largest_available >> config->base.min_align_shift, 244 251 "processing on finish_failing"); 245 246 PAS_TESTING_ASSERT(largest_available < size); 252 253 /* If we're doing an aligned allocation, then we might now skip over this view even though the 254 size we were allocating would have fit. The reason why we're doing it is that the largest size 255 we could have fit is smaller than the size class, and although it's big enough for the size being 256 requested, it's not aligned properly. */ 257 PAS_TESTING_ASSERT(largest_available < size 258 || alignment > pas_page_base_config_min_align(config->base)); 259 247 260 PAS_TESTING_ASSERT(largest_available < size_class->size); 248 261 -
trunk/Source/bmalloc/libpas/src/libpas/pas_bitfit_allocator_inlines.h
r286493 r286516 88 88 allocator->view = view; 89 89 } 90 91 if (verbose) 92 pas_log("Allocating in view %p\n", view); 90 93 91 94 bytes_committed = 0; … … 179 182 if (verbose) 180 183 pas_log("bitfit allocation succeeded with %p\n", (void*)bitfit_result.u.result); 184 185 PAS_TESTING_ASSERT(pas_is_aligned(bitfit_result.u.result, alignment)); 181 186 182 187 return pas_fast_path_allocation_result_create_success(bitfit_result.u.result); -
trunk/Source/bmalloc/libpas/src/test/TestHarness.cpp
r285789 r286516 336 336 337 337 void addBitfieldVectorTests(); 338 void addBitfitTests(); 338 339 void addBitvectorTests(); 339 340 void addCartesianTreeTests(); … … 698 699 // Run the rest of the tests in alphabetical order. 699 700 ADD_SUITE(BitfieldVector); 701 ADD_SUITE(Bitfit); 700 702 ADD_SUITE(Bitvector); 701 703 ADD_SUITE(CartesianTree);
Note: See TracChangeset
for help on using the changeset viewer.