-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Environment Information
- UMF version (hash commit or a tag): main
- OS(es) version(s): Ubuntu 22.04.5 LTS
Please provide a reproduction of the bug:
I have created PR #902 as a reproducer for this bug.
How often bug is revealed:
The bug is always reproduced on Ubuntu 22.04.4, but works fine on Ubuntu 24.04.1. Probably it is caused by different versions of libjemalloc library.
Actual behavior:
Tests are crashed with SEGFAULT. The reason is that the jemalloc pool calls memory provider with an invalid pointer and an internal check of the base allocator caught this.
Here is an output of the test enabled in the PR #902 with UMF logs.
Run on the Ubuntu22.04.4:
svinogra@gkdse-dnp-01:~/unified-memory-framework/build$ UMF_LOG="level:debug;flush:debug;output:stdout" LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH ./test/umf_test-jemalloc_pool --gtest_filter=jemallocPoolTest/umfPoolTest.allocFree/1
[INFO UMF] utils_log_init: Logger enabled (UMF version: 0.10.0-dev.git311.ga3050d4, level: DEBUG, flush: DEBUG, pid: no, timestamp: no)
[DEBUG UMF] umfMemoryTrackerCreate: tracker created, handle=0x7ff9754ad068, segment map=0x7ff9754a6008
Running main() from /user/svinogra/unified-memory-framework/build/_deps/googletest-src/googletest/src/gtest_main.cc
Note: Google Test filter = jemallocPoolTest/umfPoolTest.allocFree/1
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from jemallocPoolTest/umfPoolTest
[ RUN ] jemallocPoolTest/umfPoolTest.allocFree/1
[DEBUG UMF] umfTrackingMemoryProviderCreate: upstream=0x7ff9741f7068, tracker=0x7ff9754ad068, pool=0x7ff9754a80e8, ipcCache=0x7ff974c5e008, hIpcMappedCache=0x7ff9754b0068
[INFO UMF] umfPoolCreateInternal: Memory pool created: 0x7ff9754a80e8
[DEBUG UMF] umfMemoryTrackerAdd: memory region is added, tracker=0x7ff9754ad068, ptr=0x7ff9717ff000, pool=0x7ff9754a80e8, size=2097152
[ERROR UMF] trackingAllocationSplit: upstream provider failed to split the region
[DEBUG UMF] umfMemoryTrackerAdd: memory region is added, tracker=0x7ff9754ad068, ptr=0x7ff9741e7000, pool=0x7ff9754a80e8, size=4096
[DEBUG UMF] umfMemoryTrackerRemove: memory region removed: tracker=0x7ff9754ad068, ptr=0x7ff9741e7000, size=4096
[ERROR UMF] umfMemoryTrackerRemove: pointer 0x7ff971a00000 not found in the map
[ERROR UMF] trackingFree: failed to remove the region from the tracker, ptr=0x7ff971a00000, size=2097152, ret = 2147483646
umf_test-jemalloc_pool: /user/svinogra/unified-memory-framework/src/base_alloc/base_alloc.c:281: umf_ba_free: Assertion `pool_contains_pointer(pool, ptr)' failed.
Aborted (core dumped)
The jemalloc pool does two allocations from memory provider (see umfMemoryTrackerAdd in the log). AS a result it gets two buffers: ptr=0x7ff9717ff000, size=2097152 and ptr=0x7ff9741e7000, size=4096. At the end of the test, the jemalloc pool deallocates these buffers (see umfMemoryTrackerRemove), but one of the pointers is incorrect: [ERROR UMF] umfMemoryTrackerRemove: pointer 0x7ff971a00000 not found in the map.
Run on the Ubuntu 24.04.01:
❯ UMF_LOG="level:debug;flush:debug;output:stdout" LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH ./test/umf_test-jemalloc_pool --gtest_filter=jemallocPoolTest/umfPoolTest.allocFree/1
[INFO UMF] utils_log_init: Logger enabled (UMF version: 0.10.0-dev.git308.g64456b7, level: DEBUG, flush: DEBUG, pid: no, timestamp: no)
[DEBUG UMF] umfMemoryTrackerCreate: tracker created, handle=0x7d2c6903e068, segment map=0x7d2c69037008
Running main() from /home/vinser52/repos/unified-memory-framework/build/_deps/googletest-src/googletest/src/gtest_main.cc
Note: Google Test filter = jemallocPoolTest/umfPoolTest.allocFree/1
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from jemallocPoolTest/umfPoolTest
[ RUN ] jemallocPoolTest/umfPoolTest.allocFree/1
[DEBUG UMF] umfTrackingMemoryProviderCreate: upstream=0x7d2c68f08068, tracker=0x7d2c6903e068, pool=0x7d2c690390e8, ipcCache=0x7d2c69036008, hIpcMappedCache=0x7d2c69041068
[INFO UMF] umfPoolCreateInternal: Memory pool created: 0x7d2c690390e8
[DEBUG UMF] umfMemoryTrackerAdd: memory region is added, tracker=0x7d2c6903e068, ptr=0x7d2c67001000, pool=0x7d2c690390e8, size=2097152
[ERROR UMF] trackingAllocationSplit: upstream provider failed to split the region
[DEBUG UMF] umfMemoryTrackerAdd: memory region is added, tracker=0x7d2c6903e068, ptr=0x7d2c68eef000, pool=0x7d2c690390e8, size=4096
[DEBUG UMF] umfMemoryTrackerRemove: memory region removed: tracker=0x7d2c6903e068, ptr=0x7d2c68eef000, size=4096
[ERROR UMF] clear_tracker_for_the_pool: tracking provider of pool 0x7d2c690390e8 is not empty! (1 items left)
[INFO UMF] umfPoolDestroy: Memory pool destroyed: 0x7d2c690390e8
[ OK ] jemallocPoolTest/umfPoolTest.allocFree/1 (0 ms)
[----------] 1 test from jemallocPoolTest/umfPoolTest (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 1 test.
As you can see on the Ubuntu 24.04.01 tests passed. But there is only one deallocation (see umfMemoryTrackerRemove) while jemalloc still allocates two buffers (see umfMemoryTrackerAdd).
Expected behavior:
Test with BA_PROVIDER should pass
Details
Additional information about Priority and Help Requested:
I think there is an issue with libjemalloc. Need to confirm. If so, we need to fix our CI to use appropriate version of libjemalloc.
Requested priority: High. It blocks PR #901