Skip to content

Fix iterator invalidation bug.#224

Merged
igaztanaga merged 1 commit intoboostorg:developfrom
adalisk-emikhaylov:fix-iterator-invalidation
Aug 7, 2024
Merged

Fix iterator invalidation bug.#224
igaztanaga merged 1 commit intoboostorg:developfrom
adalisk-emikhaylov:fix-iterator-invalidation

Conversation

@adalisk-emikhaylov
Copy link
Copy Markdown
Contributor

@adalisk-emikhaylov adalisk-emikhaylov commented Jul 23, 2024

This fixes #192 and #210 (which seem to describe the same bug).

Here's the code I'm testing this on. I'm using VS 2022 (though some coworkers with the same compiler can't reproduce, I'm not entirely sure why)

#define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION 1 // This is important, doesn't crash otherwise.

#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/managed_windows_shared_memory.hpp>
#include <boost/interprocess/smart_ptr/unique_ptr.hpp>
#include <iostream>

int main()
{
    std::cout << "Before\n";
    {
        namespace bip = boost::interprocess;
        // Destructor of `x` crashes.
        auto x = bip::managed_windows_shared_memory( bip::open_or_create, "blah", bip::mapped_region::get_page_size() );
    }
    std::cout << "After\n";
}

@adalisk-emikhaylov
Copy link
Copy Markdown
Contributor Author

@igaztanaga A friendly ping.

@igaztanaga igaztanaga merged commit b155bae into boostorg:develop Aug 7, 2024
@igaztanaga
Copy link
Copy Markdown
Member

Many thanks for the pull request!

@igaztanaga igaztanaga linked an issue Aug 7, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in boost::interprocess::ipcdetail::sync_handles::obtain_mutex managed_windows_shared_memory crash on destruction

2 participants