Skip to content

Do not ignore error in os_free() when size == 0 #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
matrix:
build_type: [Debug, Release]
compiler: [{c: icx, cxx: icpx}]
pool_tracking: ['ON', 'OFF']
shared_library: ['OFF']
env:
BUILD_DIR : "${{github.workspace}}/build/"
Expand Down Expand Up @@ -53,7 +52,6 @@ jobs:
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down Expand Up @@ -88,40 +86,34 @@ jobs:
os: ['ubuntu-20.04', 'ubuntu-22.04']
build_type: [Debug, Release]
compiler: [{c: gcc, cxx: g++}]
pool_tracking: ['ON', 'OFF']
shared_library: ['OFF']
level_zero_provider: ['ON']
include:
- os: 'ubuntu-20.04'
build_type: Release
compiler: {c: gcc-7, cxx: g++-7}
shared_library: 'OFF'
pool_tracking: 'ON'
level_zero_provider: 'ON'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: clang, cxx: clang++}
shared_library: 'OFF'
pool_tracking: 'ON'
level_zero_provider: 'ON'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
pool_tracking: 'ON'
level_zero_provider: 'ON'
- os: 'ubuntu-22.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
pool_tracking: 'ON'
level_zero_provider: 'ON'
# test level_zero_provider='OFF'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
shared_library: 'OFF'
pool_tracking: 'ON'
level_zero_provider: 'OFF'
env:
BUILD_DIR : "${{github.workspace}}/build/"
Expand Down Expand Up @@ -154,7 +146,6 @@ jobs:
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down Expand Up @@ -192,27 +183,23 @@ jobs:
os: ['windows-2019', 'windows-2022']
build_type: [Debug, Release]
compiler: [{c: cl, cxx: cl}]
pool_tracking: ['ON', 'OFF']
shared_library: ['ON', 'OFF']
level_zero_provider: ['ON']
include:
- os: 'windows-2022'
build_type: Release
compiler: {c: clang-cl, cxx: clang-cl}
pool_tracking: 'ON'
shared_library: 'ON'
level_zero_provider: 'ON'
toolset: "-T ClangCL"
- os: 'windows-2022'
build_type: Release
compiler: {c: cl, cxx: cl}
pool_tracking: 'ON'
shared_library: 'ON'
level_zero_provider: 'ON'
- os: 'windows-2022'
build_type: Release
compiler: {c: cl, cxx: cl}
pool_tracking: 'ON'
shared_library: 'ON'
level_zero_provider: 'OFF'

Expand Down Expand Up @@ -242,7 +229,6 @@ jobs:
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
Expand Down Expand Up @@ -298,7 +284,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_ENABLE_POOL_TRACKING=OFF

- name: Build UMF on Linux
if: matrix.os == 'ubuntu-latest'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Release
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=OFF
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
-DUMF_FORMAT_CODE_STYLE=ON
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_ENABLE_POOL_TRACKING=ON

- name: Build UMF
run: cmake --build ${{github.workspace}}/build -j $(nproc)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/multi_numa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_ENABLE_POOL_TRACKING=ON

- name: Build UMF
run: cmake --build ${{github.workspace}}/build -j $(nproc)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ jobs:
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=${{matrix.disjoint}}
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/proxy_lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_PROXY_LIB_BASED_ON_POOL=${{matrix.proxy_lib_pool}}

- name: Build UMF
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down Expand Up @@ -88,7 +87,6 @@ jobs:
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down Expand Up @@ -153,7 +151,6 @@ jobs:
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DUMF_BUILD_SHARED_LIBRARY=OFF
-DUMF_ENABLE_POOL_TRACKING=OFF
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_ENABLE_POOL_TRACKING=ON
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
option(UMF_BUILD_BENCHMARKS_MT "Build UMF multithreaded benchmarks" OFF)
option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
option(UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF)
option(UMF_ENABLE_POOL_TRACKING "Build UMF with pool tracking" ON)
option(UMF_DEVELOPER_MODE "Enable developer checks, treats warnings as errors"
OFF)
option(UMF_FORMAT_CODE_STYLE
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ List of options provided by CMake:
| UMF_BUILD_BENCHMARKS | Build UMF benchmarks | ON/OFF | OFF |
| UMF_BUILD_EXAMPLES | Build UMF examples | ON/OFF | ON |
| UMF_BUILD_GPU_EXAMPLES | Build UMF GPU examples | ON/OFF | OFF |
| UMF_ENABLE_POOL_TRACKING | Build UMF with pool tracking | ON/OFF | ON |
| UMF_DEVELOPER_MODE | Treat warnings as errors and enables additional checks | ON/OFF | OFF |
| UMF_FORMAT_CODE_STYLE | Add clang, cmake, and black -format-check and -format-apply targets to make | ON/OFF | OFF |
| USE_ASAN | Enable AddressSanitizer checks | ON/OFF | OFF |
Expand Down
14 changes: 7 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND UMF_ENABLE_POOL_TRACKING)
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
set(EXAMPLE_NAME umf_example_basic)

add_umf_executable(
Expand All @@ -29,8 +29,10 @@ if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND UMF_ENABLE_POOL_TRACKING)
"${DLL_PATH_LIST}")
endif()
else()
message(STATUS "Basic example requires UMF_BUILD_LIBUMF_POOL_SCALABLE and "
"UMF_ENABLE_POOL_TRACKING to be turned ON - skipping")
message(
STATUS
"Basic example requires UMF_BUILD_LIBUMF_POOL_SCALABLE to be turned ON - skipping"
)
endif()

if(UMF_BUILD_GPU_EXAMPLES
Expand Down Expand Up @@ -73,7 +75,6 @@ endif()

if(UMF_BUILD_GPU_EXAMPLES
AND UMF_BUILD_LIBUMF_POOL_DISJOINT
AND UMF_ENABLE_POOL_TRACKING
AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
set(EXAMPLE_NAME umf_example_ipc_level_zero)

Expand Down Expand Up @@ -104,9 +105,8 @@ if(UMF_BUILD_GPU_EXAMPLES
else()
message(
STATUS
"IPC Level 0 example requires UMF_BUILD_GPU_EXAMPLES, "
"UMF_BUILD_LEVEL_ZERO_PROVIDER, UMF_BUILD_LIBUMF_POOL_DISJOINT and "
"UMF_ENABLE_POOL_TRACKING to be turned ON - skipping")
"IPC Level 0 example requires UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LEVEL_ZERO_PROVIDER and UMF_BUILD_LIBUMF_POOL_DISJOINT to be turned ON - skipping"
)
endif()

if(LINUX AND UMF_BUILD_LIBUMF_POOL_SCALABLE)
Expand Down
5 changes: 2 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ are used for this purpose.

### Requirements
* libtbb-dev needed for Scalable Pool
* set UMF_BUILD_LIBUMF_POOL_SCALABLE and UMF_ENABLE_POOL_TRACKING CMake
configuration flags to ON
* set UMF_BUILD_LIBUMF_POOL_SCALABLE CMake configuration flag to ON

## GPU shared memory

Expand All @@ -37,7 +36,7 @@ and build this example Level Zero development package should be installed.
### Requirements
* Level Zero headers and libraries
* compatible GPU with installed driver
* set UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LIBUMF_POOL_DISJOINT, UMF_BUILD_LEVEL_ZERO_PROVIDER and UMF_ENABLE_POOL_TRACKING CMake configuration flags to ON
* set UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LIBUMF_POOL_DISJOINT and UMF_BUILD_LEVEL_ZERO_PROVIDER CMake configuration flags to ON

## IPC example with shared memory
This example also demonstrates how to use UMF IPC API. The example creates two
Expand Down
4 changes: 0 additions & 4 deletions examples/basic/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ int main(void) {
(void *)pool, (void *)check_provider);

// Clean up.
// To free a pointer using the umfFree(ptr) function, ensure that memory tracking is enabled
// by setting the UMF_ENABLE_POOL_TRACKING option in the CMake configuration.
// If the memory tracking is disabled, you can call a different function:
// umfPoolFree(pool, ptr);
umfFree(ptr);
umfPoolDestroy(pool);
umfMemoryProviderDestroy(provider);
Expand Down
11 changes: 0 additions & 11 deletions scripts/docs_config/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ while the GPU shared uses Level Zero Memory Provider and Disjoint Pool.
There are also other memory providers and pools available in the UMF.
See `README`_ for more information.

.. note::
There are some API functions that are supported only when the UMF is built
with the memory tracking enabled (UMF_ENABLE_POOL_TRACKING=ON). These functions
are explicitly described in this tutorial as requiring memory tracking.

Basic
==============================================================================

Expand Down Expand Up @@ -113,12 +108,6 @@ Freeing memory is as easy as can be::
umfPoolDestroy(pool);
umfMemoryProviderDestroy(provider);

.. note::
To free a pointer using the :any:`umfFree` function, ensure that memory tracking is enabled
by setting the UMF_ENABLE_POOL_TRACKING option in the CMake configuration.
If the memory tracking is disabled, you should call a different function:
:any:`umfPoolFree`.

GPU shared memory
==============================================================================

Expand Down
1 change: 0 additions & 1 deletion scripts/qemu/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON \
-DUMF_ENABLE_POOL_TRACKING=ON \
-DUMF_FORMAT_CODE_STYLE=OFF \
-DUMF_DEVELOPER_MODE=ON \
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON \
Expand Down
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ else()
LIBS ${UMF_LIBS})
endif()

if(UMF_ENABLE_POOL_TRACKING)
set(UMF_PRIVATE_COMPILE_DEFINITIONS ${UMF_PRIVATE_COMPILE_DEFINITIONS}
"UMF_ENABLE_POOL_TRACKING")
endif()

target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})

target_compile_definitions(umf PRIVATE ${UMF_PRIVATE_COMPILE_DEFINITIONS})
Expand Down
9 changes: 0 additions & 9 deletions src/memory_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ void umfPoolDestroy(umf_memory_pool_handle_t hPool) {
}

umf_result_t umfFree(void *ptr) {
#ifndef UMF_ENABLE_POOL_TRACKING
return UMF_RESULT_ERROR_NOT_SUPPORTED;
#endif

umf_memory_pool_handle_t hPool = umfPoolByPtr(ptr);
if (hPool) {
return umfPoolFree(hPool, ptr);
Expand Down Expand Up @@ -125,11 +121,6 @@ umf_result_t umfPoolCreate(const umf_memory_pool_ops_t *ops,
umf_memory_pool_handle_t *hPool) {
libumfInit();

#ifndef UMF_ENABLE_POOL_TRACKING
// if tracking is not enabled during compilation, disable it for each pool here as well
flags |= UMF_POOL_CREATE_FLAG_DISABLE_TRACKING;
#endif

umf_result_t ret =
umfPoolCreateInternal(ops, provider, params, flags, hPool);
if (ret != UMF_RESULT_SUCCESS) {
Expand Down
3 changes: 1 addition & 2 deletions src/provider/provider_os_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,7 @@ static umf_result_t os_free(void *provider, void *ptr, size_t size) {

errno = 0;
int ret = os_munmap(ptr, size);
// ignore error when size == 0
if (ret && (size > 0)) {
if (ret) {
os_store_last_native_error(UMF_OS_RESULT_ERROR_FREE_FAILED, errno);
LOG_PERR("memory deallocation failed");

Expand Down
Loading