Skip to content

Multiple allocations from file provider doesn't work #796

Closed
@bratpiorka

Description

@bratpiorka

Multiple allocations from the file provider don't work - in case of multiple allocations from the file provider, all get the same pointer.

Important: when fixing this issue, make sure multiple-allocation tests are added to all providers.

Environment Information

  • UMF version (hash commit or a tag): latest
  • OS(es) version(s): Linux

Please provide a reproduction of the bug:


--- a/test/provider_file_memory.cpp
+++ b/test/provider_file_memory.cpp
@@ -80,13 +80,19 @@ struct FileProviderParamsShared : FileProviderParamsDefault {};
 static void test_alloc_free_success(umf_memory_provider_handle_t provider,
                                     size_t size, size_t alignment,
                                     purge_t purge) {
-    void *ptr = nullptr;
+    void *ptr = nullptr, *ptr2 = nullptr;
 
     umf_result_t umf_result =
         umfMemoryProviderAlloc(provider, size, alignment, &ptr);
     ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
     ASSERT_NE(ptr, nullptr);
 
+    umf_result = umfMemoryProviderAlloc(provider, size, alignment, &ptr2);
+    ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
+    ASSERT_NE(ptr2, nullptr);
+
+    ASSERT_NE(ptr, ptr2);
+
     memset(ptr, 0xFF, size);
 
     if (purge == PURGE_LAZY) {

How often bug is revealed:

always

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions